[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPATH Issue

Subject: Re: XPATH Issue
From: Rajesh Jain <rjain15@xxxxxxxxx>
Date: Tue, 30 Nov 2010 18:25:55 -0800 (PST)
 Re: XPATH Issue
The XML Document snippet is 

<?xml version="1.0" encoding="UTF-8" standalone="no"?><s:Envelope 
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><RetrieveResponse 
xmlns="http://xxx.com/webservices"><RetrieveResult><StatusType>SUCCESS</StatusType></RetrieveResult></RetrieveResponse></s:Body></s:Envelope>






----- Original Message ----
From: Rajesh Jain <rjain15@xxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Tue, November 30, 2010 9:19:44 PM
Subject: XPATH Issue

Hi

I have a very strange problem and I have spend a whole day trying to figure what 

is wrong. 


I  have a XPATH expression, and if I evaluate from a XML File on disk it  works. 

If I evaluate from a DOM Object from a HTTP Source, it doesn't  work. Both the 
documents are exactly same. 


XML Document 
SUCCESS </RetrieveResult></RetrieveResponse></s:Body></s:Envelope>


// Document from File

                // Parse the XML as a W3C document.
                DocumentBuilder builder =
                    DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document document = builder.parse(new 
File("C:\\Users\\smirxj0\\Documents\\Java\\GPN.xml"));
      

// Alternatively Document  from HTTP 
              
              InputStream isr = httpConn.getInputStream();
              Document document = builder.parse(isr);

// If I print this Document, I have the same output as the XML file


// XPATH Expression

                XPath xpath = XPathFactory.newInstance().newXPath();
                expression = "//RetrieveResponse/RetrieveResult/StatusType";
                String statusString = (String)
                    xpath.evaluate(expression, document, 
XPathConstants.STRING);      

                System.out.println("String is: " + statusString);

Please let me know where am I going wrong?

Is it a XPATH issue?

Rajesh

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.