Questions tagged [jdom-2]

JDOM 2 is the Second version of the JDOM XML API See the [Migration Guide][1] for differences over JDOM 1

JDOM 2 is the Second version of the JDOM XML API

See the Migration Guide for differences over JDOM 1

165 questions
12
votes
2 answers

How to convert String having contents in XML format into JDom document

How convert String having contents in XML format into JDom document. i am trying with below code: String docString = txtEditor.getDocumentProvider().getDocument( txtEditor.getEditorInput()).get(); SAXBuilder sb= new SAXBuilder(); doc =…
User_86
  • 265
  • 1
  • 4
  • 13
6
votes
1 answer

Document declares separate empty namespace rendering NamespaceAware results useless

I'm trying to perform some retrieval queries on a "correct" pom.xml used by maven. For that I use basic XPath queries from JDOM. Unfortunately the queries do not return any results (and neither do simple descendant filters). I'm reasonably sure that…
Vogel612
  • 5,620
  • 5
  • 48
  • 73
5
votes
1 answer

JDOM2 xpath finding nodes within a different namespace

I'm attempting to use JDOM2 in order to extract the information I care about out of a XML document. How do I get a tag within a tag? I have been only partially successful. While I have been able to use xpath to extract tags, the xpath query…
Prichmp
  • 2,112
  • 4
  • 16
  • 17
5
votes
2 answers

JDOM 2 and xpath

Here is the following code excerpted from the Spring-ws manual: public class HolidayEndpoint { private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; private XPath startDateExpression; private XPath…
Thom
  • 14,013
  • 25
  • 105
  • 185
4
votes
5 answers

JUnit ~ Assert that list contains objects with the same values in any order

My use case is that I am writing a document parser (for ReqIF documents) and want to compare that the parsed object contains the expected elements. For this, I want to write a JUnit Test. Effectively, what I am looking for is an assertion method…
Kira Resari
  • 1,718
  • 4
  • 19
  • 50
4
votes
1 answer

how to Ignore Commented content while parsing XML using JDOM2

I am facing some problem while parsing my xml using JDOM parser.It gives me the commented lines when I am trying to retrieve the content.Is there a way so that we can ignore these commented lines. Java Code: SAXBuilder jdomBuilder = new…
Manu
  • 269
  • 6
  • 18
4
votes
1 answer

JDOM2 - two Namespaces

I am trying to build the following XML structure: 1.0.0.0 true I use JDOM2 and don't know how to add 2…
user3122136
  • 161
  • 4
  • 15
4
votes
1 answer

JDOM2 with XPath doesn't work with namespace

Attempting to use XPath with an XML file that has a default namespace declared for the root node. Example code: final SAXBuilder builder = new SAXBuilder(); final Document document = builder.build(originalFile); final XPathFactory…
Thomas Beauvais
  • 1,546
  • 2
  • 16
  • 30
4
votes
1 answer

Compare two JDOM2 documents for equality

I have an application that generates XML documents using the JDOM2 library. In my unit/integration tests, I would need to compare the generated documents against handmade sample documents for equality. With standard org.w3c.dom.Document objects, I…
Dušan Rychnovský
  • 11,699
  • 8
  • 41
  • 65
4
votes
2 answers

Looking for JDOM2 XPath examples

I am using JDOM2 for the first time and I am looking for some XPATH based examples. Ex: My XML looks as follows
KK99
  • 1,971
  • 7
  • 31
  • 64
3
votes
1 answer

Insert blank lines in jdom2 pretty printing

I'm trying to simply add some blank lines to my jdom xml output. I've tried the following without luck: Element root = new Element("root"); root.addContent(new CDATA("\n")); root.addContent(new Text("\n")); I figured the all-whitespace entry was…
Didjit
  • 785
  • 2
  • 8
  • 26
3
votes
4 answers
3
votes
2 answers

How to get inner text from children XML tags using jdom2?

My XML file is structured like so: Hello, my name is ABC and my last name is XYZ I need a way to get the text output in this…
tiny_rick
  • 65
  • 1
  • 6
3
votes
1 answer

can not create the xml file using jdom

Here is my code: import java.io.FileWriter; import java.io.IOException; import org.jdom2.Attribute; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; try { Element…
marcss
  • 253
  • 2
  • 14
3
votes
1 answer

How to delete the exact element when there are multiple elements with same name?

Guys: I have a problem to remove an element from a XML file with JDOM 2.5. The problem is: under the same parent element "ApproachDat", there are multiple elements with same name as "Notes", and I only want to delete some of them based on a given…
lxiscas
  • 141
  • 1
  • 2
  • 13
1
2 3
10 11