Hi,
I am new to XML .Can any one point out to me what wrong with the following code.
-------------------------------------------
<%@ page contentType="text/html"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder " %>
<%@ page import="org.w3c.dom.*" %>
<%
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("C:\\xml\\message.xml");
NodeList n1 = doc.getElementsByTagName("messages");
%>
<html>
<body>
<%=n1.item(0).getFirstChild().getNodeValue() %>
</body>
</html>
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<message>
<messages>Hello XML .. </messages>
</message>
------------------------------------------
When I run the code above , I getting following error:
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(URL.java:480)
at java.net.URL.<init>(URL.java:376)
at java.net.URL.<init>(URL.java:330)
at com.sun.xml.parser.InputEntity.init(InputEntity.java:140)
at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
at com.sun.xml.parser.Parser.parse(Parser.java:284)
at com.sun.xml.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java
:95)
I am new to XML .Can any one point out to me what wrong with the following code.
-------------------------------------------
<%@ page contentType="text/html"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder " %>
<%@ page import="org.w3c.dom.*" %>
<%
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("C:\\xml\\message.xml");
NodeList n1 = doc.getElementsByTagName("messages");
%>
<html>
<body>
<%=n1.item(0).getFirstChild().getNodeValue() %>
</body>
</html>
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<message>
<messages>Hello XML .. </messages>
</message>
------------------------------------------
When I run the code above , I getting following error:
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(URL.java:480)
at java.net.URL.<init>(URL.java:376)
at java.net.URL.<init>(URL.java:330)
at com.sun.xml.parser.InputEntity.init(InputEntity.java:140)
at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
at com.sun.xml.parser.Parser.parse(Parser.java:284)
at com.sun.xml.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java
:95)