This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPath parser Problem" Watch "XPath parser Problem" New topic

XPath parser Problem

sivaprasad pasupulathi
Ranch Hand

Joined: Apr 21, 2009
Posts: 36

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 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 Method)
at javax.xml.parsers.DocumentBuilder.parse(

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

Paul Clapham

Joined: Oct 14, 2005
Posts: 18708

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:
subject: XPath parser Problem