• Post Reply Bookmark Topic Watch Topic
  • New Topic

XPath parser Problem  RSS feed

Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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">

<person id="2">

<person id="3">
<\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

Posts: 23262
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!