File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XPath parser Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPath parser Problem" Watch "XPath parser Problem" New topic
Author

XPath parser Problem

sivaprasad pasupulathi
Ranch Hand

Joined: Apr 21, 2009
Posts: 36
Hi

I am trying to send an input xml (as string) to the Xpath parser to build Document object.While doing this i get the following exception:Even though i am not reading from the a file it throws fileNotFoundException



java.io.FileNotFoundException: C:\eclipse\<?xml version="1.0" encoding="UTF-8"?>
<information xmlns="urn:hl7-org:v3" ITSVersion="XML_1.0">
<id extension="1"\>
<person id="1">
<name>Deep<\name>
<age>34<\age>
<gender>Male<\gender>
<\person>

<person id="2">
<name>Kumar<\name>
<age>24<\age>
<gender>Male<\gender>
<\person>

<person id="3">
<name>Deepali<\name>
<age>19<\age>
<gender>Female<\gender>
<\person>
<\information> (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:653)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)




Here is the code which i try to exceute with




The same code work when i read the xml from a file as





Could anyone point me to the solution

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18860
    
    8

Well, as you can see from your second example, the parse() method accepts a file name as its parameter. So when you pass it an XML string instead, it expects that to be a file name. But obviously your XML document is XML and not a file name at all. Hence the error message.

If you want to parse a Java string which contains XML, then you do this:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XPath parser Problem