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 7963043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:30:59+00:00 2026-06-04T05:30:59+00:00

My goal : to get the root of the XML in a Node object

  • 0

My goal : to get the root of the XML in a Node object , and then evaluate it !

My problem :

I’m trying to evaluate my expression from the ROOT of the XML file, I have this method ( I need to implement is) :

public Object evaluate(String expression, QName returnType);

Assume that I’ve already opened the XML with Document , like this :

        //load the document into a DOM Document
        this.domFactory = DocumentBuilderFactory.newInstance();

        domFactory.setNamespaceAware(true); // never forget this!

        this.builder = domFactory.newDocumentBuilder();
        this.doc = builder.parse("books.xml");

        //create an XPath factory
        this.factory = XPathFactory.newInstance();

        //create an XPath Object
        this.xpath = factory.newXPath();

Now when I do this , inside public Object evaluate(String expression, QName returnType);
:

String unitedString = " my characters " ; 
rootNode = doc.getChildNodes().item(0);
System.out.println(rootNode.getNodeName()); // this line presents the name of the root 
Object returnedObject= xpath.evaluate(unitedString,rootNode ,returnType);   // this line makes eclipse go crazy 

Eclispe says after line “4” : " DTMManagerDefault.getDTMHandleFromNode(Node) line: not available "
But in line “3” , Eclipse produces the name of the root , which is inventory …

So where did I go wrong ?

What’s wrong with it ?

Thank you all , Jack

  • 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-04T05:31:00+00:00Added an answer on June 4, 2026 at 5:31 am

    first:

    Your unitedString is not a valid xPath expression, it should be something like /root/node/ xPath’s describe paths to (a) specific node(s) to in your xml file.

    second:

    The root node of any xml is a special node called the DocumentElement, you can get to it by calling doc.getDocumentElement()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a Bill object to perform tests on. This is
I have added a .htaccess file to my root folder, and i wanted everything
I am trying to get 4 List deep List collection, List<List<List<List<int>>>> . From my
Basically I want to extract the absolute path from a node to root and
Here is a snippet of the XML file I am trying to read. <?xml
I have some code here. I recently added this root_id parameter. The goal of
This is my first time developing a rails app from scratch. The goal of
My problem is very simple. I have several folders in my root: [folder1] [folder2]
My goal is to get various SEO-relevant information for various sites. Basically all the
How do i do that? Actually my main goal is to get which checkbox

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.