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

  • SEARCH
  • Home
  • 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 990105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:53:50+00:00 2026-05-16T05:53:50+00:00

I get a XML file from website ( http://www.abc.com/ ), URL is: http://www.abc.com/api/api.xml content

  • 0

I get a XML file from website (http://www.abc.com/),

URL is: http://www.abc.com/api/api.xml

content is:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.abc.com/">
    <name>Hello!</name>
</root>

it has xmlns="http://www.abc.com/" in XML file,

now, I using JDOM XPath to get text Hello!

XPath xpath = XPath.newInstance("/root/name/text()");
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new URL("http://www.abc.com/api/api.xml"));

System.out.println(xpath.valueOf(doc)); //nothing to print...

I test to remove xmlns="http://www.abc.com/" from XML file, it’s be work!

how to change my java code to get Hello!, if xmlns="http://www.abc.com/" exist?

(I can’t chagne this XML file)

thanks for help 🙂

  • 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-05-16T05:53:51+00:00Added an answer on May 16, 2026 at 5:53 am

    You’ll need to make the query aware of the xml namespace. This answer here looks like it will do the trick:

    Default Xml Namespace JDOM and XPATH

    You might also change your query to use local-name to ignore namespaces:

    XPath xpath = XPath.newInstance("/*[local-name() = 'root']");
    

    That should return the node named root. That is, if it supports it and I typed it correctly! 🙂 I’m not familiar with java API’s for XML + XPATH.

    Be aware that xml namespaces exist to distinguish node ‘root’ from any other node named ‘root’. Just like class/package namespaces. Ignoring them could lead to a name collision. Your milage may vary.

    HTH,
    Zach

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Let's see what will be executed : main() create a… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer compiling it with gcc gives this: test.c: In function ‘read_integer’:… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer You haven't assigned anything to "instance" yet, so there's nothing… May 16, 2026 at 5:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to parse an xml file from a website. Let's say the website
HI. i am trying to open a local file from xml created by xlink
I have this XML file of size 2.8GB (Polish Wikipedia dump). I have to
I want to upload a txt file to a website, I'll admit I haven't
I have an XSLT transform I am using to process an XML file, inserting
I am reading an XML file and reorganizing the desired data into Python data
Following on from my earlier question , I am still having issues with loading
I am making a small website as my first project. I have finalized to
This post started as a question on ServerFault ( https://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined
I am attempting to get the WCF Rest Service Template 40 (CS) which is

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.