0

example...

<xml>
<level1>
<level2>
<![CDATA[ Release Date: 11/20/09 <br />View Trailer ]]>
</level2>
</level1>
</xml>

when I use inFeed.getXpath().evaluate("xml/level1/level2", myNodeList);

I get "Release Date:11/20/09 View Trailer"

I was under the impression that the whole point of CDATA is that it preserves whatever mumbo jumbo you care to throw in there. Am I using the wrong xpath expression? or am just approaching this all wrong?

1 Answer 1

3

Not sure what I'm doing differently from you but for me

public class XpathFun
{
    public static void main(String[] args) throws Exception
    {
        String xml = "<xml><level1><level2><![CDATA[ Release Date: 11/20/09 <br />View Trailer ]]></level2></level1></xml>";
        InputSource inputSource = new InputSource(new ByteArrayInputStream(xml.getBytes()));
        System.out.println(XPathFactory.newInstance().newXPath().evaluate("xml/level1/level2", inputSource));
    }
}

results in:

Release Date: 11/20/09 <br />View Trailer 
Sign up to request clarification or add additional context in comments.

1 Comment

I was doing something totally stupid... nm, thanks very much for the help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.