Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

XPath parser Problem  RSS feed

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 23640
48
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:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!