How to test for CDATA value of an element using Dom4j?

Does anybody have an idea how to find out whether an element contains <![CDATA[ text ]]> or not ? I search through the dom4j API and Jaxen and I can't find how to do that... If I retrieve the text, it the cdata wrapper is trimmed.


Technically you can still do this.

public boolean isCDATA(org.dom4j.Node node) {
  for (org.dom4j.Node n : node.content()) {
    if (org.w3c.dom.Node.CDATA_SECTION_NODE == n.getNodeType()) {
      return true;
  return false;

The method:


returns the entire element with its value unmodified by anything.

So if you have:


Calling the text methods will return "value", but calling "asXML()" will return:


From there, I guess you can do a String search for the CDATA tag.

will this work?

public short getNodeType()

Returns the code according to the type of node. This makes processing nodes polymorphically much easier as the switch statement can be used instead of multiple if (instanceof) statements.

Returns: a W3C DOM complient code for the node type such as ELEMENT_NODE or ATTRIBUTE_NODE

Need Your Help

Android custom imageview with webview-like scaling

android imageview scaling

i think this question has been asked quite often, but I couldn`t find an appropriate solution for my implementation. I built an custom imageview with an onScaleListener and an onGestureListener that

sed - insert lines when text found / not found


I have issue with sed, i need to accomplish two things with a csv file

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.