Questions tagged [dom4j]

dom4j is an open source library for working with XML, XPath and XSLT on the Java platform using the Java Collections Framework and with full support for DOM, SAX and JAXP.

dom4j is an open source library for working with XML, XPath and XSLT on the Java platform using the Java Collections Framework and with full support for DOM, SAX and JAXP.

Features:

  • designed for the Java platform with full support for the Java Collections Framework (Java 2 Collections)
  • full support for JAXP, TrAX, SAX, DOM, and XSLT
  • fully integrated XPath support for easy navigation of XML documents
  • event based proccessing mode to support for massive documents or XML streams based on Java interfaces for flexible plug and play implementations
  • support for XML Schema Data Type support using Kohsuke Kawaguchi's excellent Multi Schema Validator library
323 questions
389
votes
7 answers

XPath contains(text(),'some string') doesn't work when used with node with more than one Text subnode

I have a small problem with XPath contains with dom4j ... Let's say my XML is ABC 5 BLAH BLAH BLAH

ABC
Let's say I want to…
Mike Milkin
  • 3,961
  • 4
  • 17
  • 10
74
votes
11 answers

What Java XML library do you recommend (to replace dom4j)?

I'm looking for something like dom4j, but without dom4j's warts, such as bad or missing documentation and seemingly stalled development status. Background: I've been using and advocating dom4j, but don't feel completely right about it because I know…
Jonik
  • 80,077
  • 70
  • 264
  • 372
22
votes
5 answers

Using Xpath in Dom4j

I get the following exception when trying to access any nodes of a parsed xml document on dom4j: Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at…
11
votes
2 answers

Java dom4j org/jaxen/NamespaceContext exception

I have downloaded dom4j-1.6.1 and added it to java's build path. I am also familiar with java.lang.NoClassDefFoundError: org/saxpath/SAXPathException but I keep getting an exception. Enclosed a snippet: public class Parser { public static void…
Mr.
  • 9,429
  • 13
  • 58
  • 82
10
votes
3 answers

Getting attribute value from node using dom4j

My XML is structured like the example below. I'm trying to get the attribute values out of XML using dom4j. Currently the nodes are stored into a List with…
anjunatl
  • 1,027
  • 2
  • 11
  • 24
9
votes
3 answers

how to convert dom4j document object to string

Just trying to find a way to convert a Dom4J Document content to String. It has a asXML() API which converts the content to a XML. In my case,I'm editing a non-xml DOM structure using Dom4J and trying to convert the content to String. I know its…
Shamik
  • 1,671
  • 11
  • 36
  • 64
8
votes
2 answers

Dom4j selectNodes(arg) don't give list of nodes

I am using DOM4j for XML work in java, my xml is like this:
user1808932
  • 427
  • 1
  • 5
  • 14
8
votes
5 answers

Clean namespace handling with dom4j

We are using dom4j 1.6.1, to parse XML comming from somewhere. Sometime, the balise have mention of the namespace ( eg : ) and sometime not ( ). And it's make call of Element.selectSingleNode(String s ) fails. For now we have 3 solutions, and we…
Antoine Claval
  • 4,923
  • 7
  • 40
  • 68
7
votes
1 answer

Problem with conversion of org.dom4j.Document to org.w3c.dom.Document and XML Signature

I have some classes that already use DOM4J to read XML files and provide getter methods to the data. Now, I need to add the possibility of checking XML digital signatures. Using org.w3c.dom and following…
user635056
6
votes
1 answer

How can I insert a node before an other using dom4j?

I have a org.dom4j.Document instance that is a DefaultDocument implementation to be specific. I would like to insert a new node just before an other one. I do not really understand the dom4j api, I am confused of the differences between Element and…
jabal
  • 11,987
  • 12
  • 51
  • 99
5
votes
2 answers

java.lang.NoClassDefFoundError: org/dom4j/Document

I have a class called XMLtoXML.java and this is one of it's methods... import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.Node; import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; public Object[] process(Object data)…
sa9689
  • 65
  • 1
  • 2
  • 7
5
votes
1 answer

How efficient is XPath compared to using DOM in Dom4J?

For example consider the following xml some content1 some content2 …
Prabhu R
  • 13,836
  • 21
  • 78
  • 112
5
votes
2 answers

Using dom4j DOMDocument to feed validator.validate(DOMSource) fails in java 1.6 (xsi:noNamespaceSchemaLocation is not allowed), works in 1.5

Using dom4j DOMDocument to feed validator.validate(DOMSource) fails in java 1.6 (with xsi:noNamespaceSchemaLocation is not allowed to appear in root element), works in 1.5 I'm finding the following problem quite intractable (OK, that's an…
user598656
  • 442
  • 7
  • 10
5
votes
2 answers

Implicit conversion between Scala collection types

I would like to implicitly convert between the Scala XML Elem object and another representation of an XML element, in my case dom4j Element. I wrote the following implicit conversions: implicit def elemToElement(e: Elem): Element = ... do conversion…
ebruchez
  • 7,760
  • 6
  • 29
  • 41
5
votes
2 answers

ClassNotFoundException: org.dom4j.DocumentException

I am trying to debug (F11 on Eclipse) a java GUI application I inherited but while the application runs fine (minus a tiny fix I need to apply) outside of the Eclipse IDE, it produces the following exception when launched from Eclipse (either F11 or…
Withheld
  • 4,603
  • 10
  • 45
  • 76
1
2 3
21 22