Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:28:02+00:00 2026-06-17T11:28:02+00:00

I am using DOM4j for XML work in java, my xml is like this:

  • 0

I am using DOM4j for XML work in java,
my xml is like this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<abcd name="ab.catalog" xmlns="http://www.xyz.com/pqr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyz.com/pqr ./abc.xyz.xsd">             
<efg>
......
</efg>
<efg>
.....
</efg>
</abcd>

then,

List<Node>list = document.selectNodes("/abcd/efg");

gets the size of list zero. I feel it’s due to namespace specified in the xml.
I tried a lot but cn’t get success.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:28:03+00:00Added an answer on June 17, 2026 at 11:28 am

    Unprefixed element names in XPath expressions refer to elements that are not in a namespace – they do not take account of the “default” xmlns="..." namespace declared on the document. You need to declare a prefix for the namespace in the XPath engine and then use that prefix in the expression. Here is an example inspired by the DOM4J javadocs:

    Map uris = new HashMap();
    uris.put("pqr", "http://www.xyz.com/pqr");
    XPath xpath = document.createXPath("/pqr:abcd/pqr:efg");
    xpath.setNamespaceURIs(uris);
    List<Node> nodes = xpath.selectNodes(document);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using dom4j to parse my xml. Let's say I have something like this:
I'm using dom4j to create XML documents from entities. I'm doing something like: Entity
In a Java program, i am processing an xml using dom4j. Now, I want
I'm reading a XML file with dom4j. The file looks like this: ... <Field>&#13;&#10;
I have an XML Schema element like this: <xs:element type=xs:string name=IsActive minOccurs=0> </xs:element> I'm
I am trying to use dom4j to validate the xml at http://www.w3schools.com/Schema/schema_example.asp using the
Using range() in Underscore I can make something like this: _.range(10); >> [0, 1,
I'm trying to get cdata text from a node using dom4j java. My issue
I'm using dom4j to parse a xml file in order to get some data
I am using DOM4J to do analysis of two XML elements. The elements are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.