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

XPath Question (related to Java)

Subject: XPath Question (related to Java)
From: "Grant Slade" <grant.slade@xxxxxxxxx>
Date: Sun, 24 Jun 2007 12:03:17 -0600
 XPath Question (related to Java)
Hi, I have the following xml which gets read from a file as part of a Node:
           <Definition> An organic compound in which the aldehyde
group (HC=O) is connected to a branched or unbranched open chain of
carbon atoms rather than a ring. Some aldehydes are created during the
reactions of oxidants used as disinfectants, particularly ozone
(O<sub>3</sub>), with natural organic matter. </Definition>

When I run it through the following method  it ignores the <sub></sub>:
     public String getDefinitionFromNode(Node node) throws
javax.xml.xpath.XPathExpressionException
     {
           XPath xpath = XPathFactory.newInstance().newXPath();
           String definitionExpression = "Definition";
           String definition = (String)
xpath.evaluate(definitionExpression, node, XPathConstants.STRING);
           if(definition.contains("<"))
                 System.out.println ("found a <");
           else
           {
                 System.out.println ("did not find a <");
           }
           return definition;
     }

When the program runs, it outputs the following:

did not find a <
--------------------------------
<dictionary n=""><TermName>aliphatic aldehyde</TermName><Definition>An
organic compound in which the aldehyde group (HC=O) is connected to a
branched or unbranched open chain of carbon atoms rather than a ring.
Some aldehydes are created during the reactions of oxidants used as
disinfectants, particularly ozone (O3), with natural organic
matter.</Definition></dictionary>

How do I get it to output the <sub></sub> elements?

The complete node is:
       <Term>
           <Entry> aliphatic aldehyde </Entry>
           <Definition> An organic compound in which the aldehyde
group (HC=O) is connected to a
               branched or unbranched open chain of carbon atoms
rather than a ring. Some aldehydes
               are created during the reactions of oxidants used as
disinfectants, particularly
               ozone (O<sub>3</sub>), with natural organic matter.
</Definition>
           <SeeAlso>disinfection by-product</SeeAlso>
           <IMAGE fileName="A-17.gif"/>
       </Term>

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.