parsing with dom4j -- NullPointerException

dom4j-user
Sukh
2010-08-19
2012-10-08
  • Sukh
    Sukh
    2010-08-19

    I am successfully retrieve the data of response using xpath expression
    /abcde/response from the xml ,

    <abcde>
                <response>000</response>
    </abcde>
    

    But couldnt retrieve the data of response from the same xml but with some
    additional data

    <abcde version="8.1" xmlns="[url]http://www.litle.com/schema[/url]"
          response="0" message="Valid Format">
                <response>000</response>
    </abcde>
    

    Here is the code snippet i am using
    Document document = DocumentHelper.parseText(<above xml="" string="">);
    Node respNode = document
    .selectSingleNode("/abcde/response");

    System.out.println(respNode.getText()); // Nullpointerexception thrown here

    What am i doing wrong ?

     
  • Sukh
    Sukh
    2010-08-20

    seems the xml took some errorneouc chars while pasting . There is no ";" in
    the second xml in <abcde version="8.1" xmlns="&lt;a class=" "="" href="http://www.litle.com/schema">http://www.litle.com/schema";
    response="0" message="Valid Format"> ...

    The acutal xml will look like
    <abcde version="8.1" xmlns="&lt;a class=" "="" href="http://www.litle.com/schema">http://www.litle.com/schema"
    response="0" message="Valid Format">