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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:07:42+00:00 2026-05-19T05:07:42+00:00

I have a simple XML document <abc:MyForm xmlns:abc=’http://myform.com’> <abc:Forms> <def:Form1 xmlns:def=’http://decform.com’> …. </def:Form1> <ghi:Form2

  • 0

I have a simple XML document

<abc:MyForm xmlns:abc='http://myform.com'>
    <abc:Forms>
        <def:Form1 xmlns:def='http://decform.com'>
            ....
        </def:Form1>
        <ghi:Form2 xmlns:ghi='http://ghiform.com'>
            ....
        </ghi:Form2>
    </abc:Forms>
</abc:MyForm>

I’m using XMLObjects from Apache and when I try to do the following xpath expression it works perfectly

object.selectPath("declare namespace abc='http://myform.com' 
                   abc:Form/abc:Forms/*");

this gives me the 2 Form nodes (def and ghi). However I want to be able to query by specifying a namespace, so let’s say I only want Form2. I’ve tried this and it fails

object.selectPath("declare namespace abc='http://myform.com' 
                   abc:Form/abc:Forms/*
                      [namespace-uri() = 'http://ghiform.com']");

The selectPath returns 0 nodes. Does anyone know what is going on?

Update:

If I do the following in 2 steps, then I can get the result that I want.

 XmlObject forms = object.selectPath("declare namespace abc='http://myform.com' 
                   abc:Form/abc:Forms")[0];
 forms.selectPath("*[namespace-uri() = 'http://ghiform.com']");

this gives me the ghi:Form node just like it should, I don’t understand why it doesn’t do it as a single XPath expression though.
Thanks

  • 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-19T05:07:42+00:00Added an answer on May 19, 2026 at 5:07 am

    The simple answer is that you can’t. The namespace prefix is just a shorthand for the namespace URI, which is all that matters.

    For a namespace-aware parser, your two tags are identical.

    If you really want to differentiate using the prefix (although you really, really shouldn’t be doing it), you can use a non namespace-aware parser and just treat the prefix as if it was part of the element name.

    But ideally you should read a tutorial on how namespaces work and try to use them as they were designed to be used.

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

Sidebar

Related Questions

I have an xml document that contains spaces and equal signs in the node
I have a maven library project with some classes to deal xml messages. Whenever
I have a string containing field/value pairs in xml format and want to parse
I need to create a PHP script that receives XML input via an HTTP
I am trying to use an XMLHTTPRequest to download an .xml file and add
I'm running myself around in circles here and the answer should be so simple.
I've written a very simple batch script that will do an XSLT transform for
Is it possible to include variables in a web.config transform file? For each environment,
I was just curious what's the best way to store data for use by
I am working on an application that has a large set of configuration values,

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.