Parsing XML string with XPath

Hi,-
I am trying to parse an XML string with xpath as follows but I am getting null for getresult.
I am getting java.xml.xpath.xpathexpressionexception at line where
getresult = xpathexpression.evaluate(isource); is executed.
What should I do after
xpathexpression = xPath.compile("a/b");in the below snippet?
Thanks
String xmlstring ="..."; // a valid XML string;
Xpath xpath = XPathFactory.newInstance().newPath();
xpathexpression = xPath.compile("a/b");
// I guess the following line is not correct
InputSource isource = new inputSource(new ByteArrayInputStream(xmlstring.getBytes())); right
getresult = xpathexpression.evaluate(isource);My xml string is like:
<a>
  <b>
     <result> valid some more tags here
     </result>
  </b>
  <c> 10
  </c>
</a>Edited by: geoman on Dec 8, 2008 2:30 PM

I've never used the version of evaluate that takes an InputSource. The difficulty with using it is that it does not save the DOM object. Each expression you evaluate will have to create the DOM object, use it once and then throw it away. I've yet to write a program that only needs one answer from an XML document. Usually, I use XPath to locate somewhere in a document and then read "nearby" content, add new content nearby, delete content, or move content. I'd suggest you may want to parse the XML stream and save the DOM Document.
Second, all of the XPath expressions search from a "context node". I have not had good luck searching from the Document object, so I always get the root element first. I think the expression should work if you use the root as the context node. You will need one of the versions of evaluate that uses an Object as the parameter.

Similar Messages

  • Parse xml document with xpath

    I would like to parse an xml document using xpath, see:
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    however, in the documentation (in the link above), it states that I need J2SE 5.0.
    Currently, I have:
    $ java -version
    java version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    Does that mean that I really have to install J2SE 5.0 in order to use J2SE 5.0's XPath support? Does anybody know anything about getting started with XPath, and whether I can just use my existing version of Java? I've never used XPath.
    For more documentation, one can view:
    http://www.w3.org/TR/xpath20/
    Thank you.

    I have copied the code for the xpath tutorial on
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    exactly as it is on the tutorial, and imported the correct jars (I think).
    But still my code is giving lots of errors!
    Granted its my first shot but anyway here's the code and the errors...
    package test;
    import org.jdom.xpath.*;
    import java.io.*;
    import javax.xml.xpath.*;
    public class XPath {
         public static void main (String [] args){
              XPathFactory factory = XPathFactory.newInstance();
              XPath xPath=factory.newXPath();
              XPathExpression  xPathExpression=xPath.compile("/catalog/journal/article[@date='January-2004']/title");
              File xmlDocument = new File("/home/myrmen/workspace/Testing/test/catalog.xml");     
              //FileInputStream fis = new FileInputStream(xmldocument); 
              InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
              String title = xPathExpression.evaluate(inputSource);
              String publisher = xPath.evaluate("/catalog/journal/@publisher", inputSource);
              String expression="/catalog/journal/article";
              NodeSet nodes = (NodeSet) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
              NodeList nodeList=(NodeList)nodes;
              SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
              org.jdom.Document jdomDocument = saxBuilder.build(xmlDocument);
              org.jdom.Attribute levelNode = (org.jdom.Attribute)(XPath.selectSingleNode(jdomDocument,"/catalog//journal[@title='JavaTechnology']" + "//article[@date='January-2004']/@level"));
              levelNode.setValue("Intermediate");
              org.jdom.Element titleNode = (org.jdom.Element) XPath.selectSingleNode( jdomDocument,"/catalog//journal//article[@date='January-2004']/title");
              titleNode.setText("Service Oriented Architecture Frameworks");
              java.util.List nodeList = XPath.selectNodes(jdomDocument,"/catalog//journal[@title='Java Technology']//article");
              Iterator iter=nodeList.iterator();
              while(iter.hasNext()) {
                   org.jdom.Element element = (org.jdom.Element) iter.next();
                   element.setAttribute("section", "Java Technology");
              XPath xpath = XPath.newInstance("/catalog//journal:journal//article/@journal:level");
              xpath.addNamespace("journal", "http://www.w3.org/2001/XMLSchema-Instance");
              levelNode = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
              levelNode.setValue("Advanced");
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Type mismatch: cannot convert from XPath to XPath
         The method compile(String) is undefined for the type XPath
         InputSource cannot be resolved to a type
         InputSource cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeList cannot be resolved to a type
         NodeList cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         The method selectSingleNode(Document, String) is undefined for the type XPath
         The method selectSingleNode(Document, String) is undefined for the type XPath
         Duplicate local variable nodeList
         The method selectNodes(Document, String) is undefined for the type XPath
         Iterator cannot be resolved to a type
         The method newInstance(String) is undefined for the type XPath
         The method addNamespace(String, String) is undefined for the type XPath
         The method selectSingleNode(Document) is undefined for the type XPath
         at test.XPath.main(XPath.java:12)

  • Getting null value while parsing "XML String" with  encoding WINDOWS-1252.

    Hi,
    when I am converting the Follwoing "xml string " to Document, I am getting the "null" as a document value.
        String strXML =  "<?xml version="1.0" encoding="WINDOWS-1252"?>
                              <category name="SearchByAttributes" value="Search By Attributes">
                                <item name="ORDER_LINE_ID" description="Application Search Attributes" >
                                   <attribute name="Sequence" value="0001"/>
                                 </item>
                                </category>"      
    My "xml string" has the encoding vaule: WINDOWS-1252.
    I am using the following code to convert the "xml string" to Document. I am getting the Document values as a "null" while converting the above "string xml"
            String strXML = //my above string xml.
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setIgnoringElementContentWhitespace(true);
            docBuilder = docBuilderFactory.newDocumentBuilder();
            doc = docBuilder.parse(new InputSource(new StringReader(strXML)));              
            System.out.println("doc value.."+doc)//I am getting null value for "doc".
    Can anyone help me to resolve the issue.

    Thagelapally wrote:
    I am coverting the below "XML string" to Document, once it is converted I am reading that Document,which have an "attribue" Element in.
      String strXML = "<?xml version="1.0" encoding="WINDOWS-1252"?>
    <category name="SearchByAttributes" value="Search By Attributes">
    <item name="ORDER_LINE_ID" description="Application Search Attributes" >
    <attribute name="Sequence" value="0001"/>
    </item>
    </category>" I am using the above code to read the Document. When run the code in "OC4J Server" and using Jdeveloper as an editor,I am able to perfectly read the "attribute" element in the document with out any problem.Println statement printing as I expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."attribute"(as expected)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."oracle.xml.parser.v2.XMLAttrList@afe"But when run the same code(reading the same Document) in Tomcat and Eclipse,println satatement not printing as i expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."#text"(I am expecting output value "attribute" but it is printing "#text" which i don't know)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."null"(I am expecting output value object reference but it is printing "null"
    (without the rest of the code, i'm guessing that) most likely you are grabbing the first child node of the item element. however, you are not accounting for some text nodes that are most likely in that list, like the whitespace between the item element and the attribute element. please go read some tutorials on xml, there are thousands of them out there, and they will answer all you initial questions much more efficiently than posting each step to the forums.

  • Spry can not  parse xml string

    while designind an mvc architecutre in php I found display
    data on site was slow so I generate a xml sheet an used spry Data
    loading was fast an dproduced and I also performed many operations
    like sorting ,galeery making ..etc... but main thing is that I can
    not parse a xml string using spry only a xml file can be parsed
    my application required to parse xml string

    I'm not sure if this is valid in your situation, but OC4J comes with Oracle XMLParser.
    Simply use the JAXP API to parse/build/modify XML and the Oracle XMLParser implementation will be used behind the scenes.
    If you must use xerces/xalan, try putting the jars in OC4J_HOME/j2ee/home/lib instead.
    HTH //Anders

  • Escape XML Strings with JDK class

    Hi,
    can anyone tell me how to escape XML-Strings with classes of the JDK?
    When searching I only was pointed to StringEscapeUtils from apache.commons.lang, but we would prefer to use the JDK instead of integrating an external lib.
    Our aim is to escape an XML attribute, so a CDATA is not applicable for us in this case.
    Thanks
    Jan

    I implemented it by myself:
    public static String escapeXmlAttribute(String attributeValue) {
            StringBuffer result = new StringBuffer();
            for (int c = 0; c < attributeValue.length(); ++c) {
                if (attributeValue.charAt(c) == '"') {
                    result.append("&#34;");
                } else if (attributeValue.charAt(c) == '&') {
                    result.append("&#38;");
                } else if (attributeValue.charAt(c) == '<') {
                    result.append("<");
                } else if (attributeValue.charAt(c) == '>') {
                    result.append(">");
                } else {
                    result.append(attributeValue.charAt(c));
            return result.toString();
        }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Getting Error while creating Document object  after  parsing XML String

    Hi All,
    I have been trying to parse an XML string using the StringReader and InputSource interface but when I am trying to create Document Object using Parse() method getting error like
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    Please find the code below which i have been experimenting with:
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.List;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import java.io.*;
    public class TestMain {
         public static void main(String[] args) {
              String file = "";
              file = loadFileContent("C:\\Test.xml");
              System.out.println("contents >> "+file);
              parseQuickLinksFileContent(file);
    public static void parseQuickLinksFileContent(String fileContents) {
    PWMQuickLinksModelVO objPWMQuickLinksModelVO = new PWMQuickLinksModelVO();
         try {
    DocumentBuilderFactory factory =           DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         StringReader objRd = new StringReader(fileContents);
         InputSource objIs = new InputSource(objRd);
         Document document = builder.parse(objIs); // HERE I am getting Error.
         System.out.println(document.toString());
    What is happening while I am using builder.parse() method ???
    Thanks,
    Rajendra.

    Getting following error
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.

  • How to parse XML string fetched from the database

    i want to parse the XML string which is fetched from the oracle database.
    i have inserted the string in xml format in the database. The type of the field in which it is inserted is varchart2.
    I am successfully getting it using jdbc, storing it in a String.
    Now it is appended with xml version 1.0 and string is ready for parsing.
    Now i am making following programming.
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = Builder.parse(xmlString);
    Element root = doc.getDocumentElement();
    NodeList node = root.getElementsByTagName("product");
    But i am getting IOException at the statement
    Document doc = Builder.parse(xmlString);
    there fore i request u to kindly help me in solving this error.
    -regards
    pujan

    DocumentBuilder does not have a method parse with xml string as aparameter. The string should be a xml document uri.
    Convert xml string to StringReader.
    parse(new InputSource(new StringReader(xmlString)));

  • JDOM: Parsing XML String, getting error

    Hello,
    I am new to this forum, so please forgive me
    if this has already been asked before. I want to
    parse an XML string. I know the JDOM parser works
    great with a file, but apparently I have been
    unsuccessful parsing an XML String. Below is how I
    initialize the parser:
    import java.io.*; //Import proper packages
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.output.*;
    import java.util.*;
    import java.lang.*;
    public class XMLParser{
    private Document doc = null;
    public XMLParser(String xml){
    doc = readDocument(xml);
    private Document readDocument(String xml) {
    try {
    SAXBuilder builder = new SAXBuilder();
    org.jdom.Document result = builder.build(new
    StringReader(xml));
    return result;
    } catch(JDOMException e) {
    e.printStackTrace();
    } catch(NullPointerException e) {
    e.printStackTrace();
    return null;
    } //readDocument
    The following is the error I receive:
    JDOM/xmlparser.java [81:1] cannot resolve symbol
    symbol : method build (java.io.StringReader)
    location: class org.jdom.input.SAXBuilder
    org.jdom.Document result = builder.build(new
    StringReader(filename));
    --> Arrow pointing to builder.build
    Please if someone can help me out. If JDOM does not
    have this feature, then can someone please recommend a
    parser that can parse an XML String.

    Thank you for your help, although it seems like it was JDom 9 beta. When I tried with JDOM 8 beta, everything worked fine even with the StringReader. So if anyone is having similar problems with JDom 9 then try with JDom 8.

  • How to parse XML file with namesapce?

    Hi,
       I am trying to parse an xml file having namespace. But no data is returned.
    Sample Code:
    public class XMLFileLoader
    var xml:XML = new XML();
    var myXML:XML = new XML();
    var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
    var myLoader:URLLoader = null;
    public function XMLFileLoader()
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    myLoader= new URLLoader(myXMLURL);
    myLoader.addEventListener(Event.COMPLETE,download);
    public function download(event:Event):void
    myXML = XML(myLoader.data);
    var ns:Namespace=myXML.namespace("xsi");
    for(var prop:String in myXML)
         trace(prop);
    //Alert.show(myXML..Parameters);
    //trace("Data loadedww."+myXML.toString());
    //Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
    The XML Contains the following format.
    <Network xmlns="http://www.test.com/2005/test/omc/conf"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
        <TestDomain>
          <WAC>
            <!--Release Parameter  -->
            <Parameters ParameterName="ne_release" OutageType="None"
                        accessRight="CreateOnly" isMandatory="true"
                        Planned="false"
                        Reference="true" Working="true">
              <DataType>
                <StringType/>
              </DataType>
              <GUIInfo graphicalName="Release"
                       tabName="All"
                       description="Describes the release version of the managed object"/>
            </Parameters>
    </TestDomain>
    </Network>
    Any sample code how to parse this kind of xml file with namespaces...
    Regards,
    Purushotham

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • Help: How to parse XML string into Node Context

    Hi Experts,
    I am trying to work with a web dynpro for java application which calls a Web Service. I can call the web service successfully, however I have a problem on interpreting the response result into table. The response result is in (XML) string format, like this:
    I followed this , but it resulted to an error:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)(:main:, row=158, col=59) -> com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)
    do anyone of you had a similar experience and were able to resolve it, please post it here. it will be highly appreciated. thanks in advance.

    Try this :
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps.

  • How to parse xml string

    Hi! I'm having problems parsing an xml string. I've done DOM and SAX parsing before. But both of them either parse a file or data from an input source. I don't think they handle strings. I also don't want to write the string into a file just so I can use DOM or SAX.
    I'm looking for something where I could simply do:
    Document doc = documentBuilder.parse( myXMLString );
    So the heirarchy is automatically established for me. Then I could just do
    Element elem = doc.getElement();
    String name = elem.getTagName();
    These aren't the only methods I would want to use. Again, my main problem is how to parse xml if it is stored in a string, not a file, nor comming from a stream.
    thanks!

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • Passing / parsing XML String IN / OUT from PL / SQL package

    Hello, People !
    I am wondering where can I find exact info (with code sample) about following :
    We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
    and the return some kind of cursor thru I can loop and insert data into
    different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
    I looked online many site for related info - can't find what I am looking
    for - seems like should be a common question.
    Thanx a lot !

    Hello, People !
    I am wondering where can I find exact info (with code sample) about following :
    We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
    and the return some kind of cursor thru I can loop and insert data into
    different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
    I looked online many site for related info - can't find what I am looking
    for - seems like should be a common question.
    Thanx a lot !

  • Parse xml string not file

    Hi
    Can anyone help me I am trying to parse a xml file that is in a StringBuffer and not a file.
    Any suggestions would be great.
    Thanks ;>

    You can create a StringReader object from your StringBuffer. Once you have a StringReader object, you can create an InputSource object. Then, you can parse the InputSource with a DocumentBuilder object. I enclosed the code to illustrate. The method printXml is only used to check that the XML string is properly parsed and retrieved.
    import java.io.IOException;
    import java.io.StringReader;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Attr;
    import org.w3c.dom.Document;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    public class Parsing
        public static void main(String[] args)
         StringBuffer yourStringBuffer = new StringBuffer("<message>"
                                        +"<header>This is the message's header</header>"
                                        + "<body>This is the message's body</body>"
                                        + "</message>");
         try {
             DocumentBuilderFactory docBuilderFactory = new org.apache.crimson.jaxp.DocumentBuilderFactoryImpl();
             //throws ParserConfigurationException
             DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
             StringReader strReader = new StringReader(yourStringBuffer.toString());
             //throws SAXException, IOException, IllegalArgumentException
             Document doc = docBuilder.parse(new InputSource(strReader));
             System.out.println(printXml(doc)); //check if the XML can be retreived, i.e. it has been parsed successfully
         catch(ParserConfigurationException ex) {
             ex.printStackTrace();        
         catch(SAXException ex) {
             ex.printStackTrace();
         catch(IOException ex) {
             ex.printStackTrace();
         catch(IllegalArgumentException ex) {
             ex.printStackTrace();
        //Convenient method to print a Document object.
        public static String printXml(Document xmlDoc)
         StringBuffer xml = new StringBuffer("************ Xml Document *************");
         print(xmlDoc,xml);
         return xml.toString();
        protected static void print(Node node, StringBuffer strXml)
         int type;
         String elementName;
         Node childNode;
         NamedNodeMap attrs;
         Attr attrib;
         NodeList childNodes;
         strXml.append(System.getProperty("line.separator"));
         if(node == null)
             return;
         type = node.getNodeType();
         switch (type) {
         case Node.DOCUMENT_NODE: {
             print(((Document)node).getDocumentElement(),strXml); //recursive call to browse the tree
             break;
         case Node.ELEMENT_NODE: {
             elementName = node.getNodeName();
             strXml.append("<" + elementName);
             attrs = node.getAttributes();
             if(attrs == null)
              strXml.append(">");
             else {
              for(int i = 0; i < attrs.getLength(); i++) {
                  attrib = (Attr) attrs.item(i);
                  strXml.append(" " + attrib.getName() + "=\"" + attrib.getValue() + "\"");
              strXml.append(">");
             childNodes = node.getChildNodes();
             if(childNodes == null) return;
             for (int i = 0; i <  childNodes.getLength(); i++) {
              childNode = childNodes.item(i);
              if(childNode.getNodeType() == Node.TEXT_NODE)
                  strXml.append(childNode.getNodeValue());
              else
                  print(childNode,strXml);
             strXml.append(System.getProperty("line.separator"));
             strXml.append("</" + elementName + ">");
    }Hope this helps.

  • Getting a complete portion of an XML String (With tag names)

    Im working on an application that processes a huge amount of xml strings. Im using xpath since it makes it much easier to select and navigate through the tags. The only thing I can't do is get a complete portion of an XML string, for example, if i have
    <article>
    <articlebody>
    </articlebody>
    <references>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    </references>
    </article>
    I need to get the complete <reference> portion to parse later, so i need the following string:
    <references>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    </references>
    How can i do this using xpath? is it even possible? if not how else can i do it? (don't want to use regular expressions and string manipulation)
    Thanks for you help

    Im not sure if this really qualifies as using DOM, but this is all i do to get the data i want from the files (when i only want to get the text value of an element:
    InputSource inputSource = new InputSource(new StringReader(metadata));
    return xpath.evluate(expression, inputSource, returnType);where metadata is a String containing meta data, and return type is usually string or number.
    Im using Java 5 and
    Could you please explain a little more how to do this?
    Thank you

  • Parsing XML Strings

    I am getting an XML String from a web-service.. Is there a method inside of BPM to parse this xml string?

    Hi, my xml string is:-
    <?xml version="1.0" encoding="UTF-8" ?>
    <ns2:Exception xmlns:ns2="http://example.com/" >
         <errorCode>0</errorCode>
         <errorSubcode>0</errorSubcode>
         <message>Connection refused</message>
         <messageWithProperties>Connection refused
         Error Code=[0]
         ticketId=[1]
         fileName=[testFile]
    </messageWithProperties>
         <properties>
              <name>Error Code</name>
              <value>0</value>
         </properties>
         <properties>
              <name>ticketId</name>
              <value>1</value>
         </properties>
         <properties>
              <name>fileName</name>
              <value>testFile</value>
         </properties>
         <propertiesAsString>     Error Code=[0]
         ticketId=[1]
         fileName=[testFile]
    </propertiesAsString>
    </ns2:Exception>
    I wanted to parse through it and get the errorCode....
    I am using :-
    xmlObject.load(xmlText : xmlContent);
    xmlMessage = xmlObject.selectString(xpath : "/ns2/errorCode");
    But this doesn't seem to work..
    Any idea?

Maybe you are looking for

  • How to save a Module in Visual Basic with Excel for Mac 2011

    On the MS support pages it shows how to create a module that will turn digits into written words: http://support.microsoft.com/kb/213360/en-us so if you enter $32.50 it will convert it to Thirty-Two Dollars and 50 cents. Perfect for batch payroll wor

  • To shrink the size of TEMP tablespace

    Dear all, There is a databse with RAC, now in OEM the size of TEMP tablespace has been reached at 99.9%. now we want to shrink the size of TEMP tablespace. how to we do that??????? plz help me...........

  • Suppress multiple alerts (created manually)

    Hi all, do you know of any option to suppress multiple alerts created with report SALERT_CREATE? (/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function) For those "automatic" alerts created by PI and raised throug

  • Fatal error in startNodeManager.sh

    I when I try to start the node manager I obtain the following error: <Fatal error in node manager server> java.net.UnknowHostException: startNodemanager.sh thanks any help

  • OMG. I bought 3 songs & it wont dowload. :( Help.

    Err.. Umm.. okay well i purchased 3 songs from the i-tunes store and it said "downloading 1 of 3" then like.. the songs started disapearring one by one.. then at the end it said something like.. Error. Could not download songs. And it said something