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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:55:06+00:00 2026-05-27T18:55:06+00:00

I have the following XML: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <application xmlns=http://research.sun.com/wadl/2006/10> <doc xmlns:jersey=http://jersey.dev.java.net/ jersey:generatedBy=Jersey:

  • 0

I have the following XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://research.sun.com/wadl/2006/10">
<doc xmlns:jersey="http://jersey.dev.java.net/" 
     jersey:generatedBy="Jersey: 1.0.2 02/11/2009 07:45 PM"/>
<resources base="http://localhost:8080/stock/">
    <resource path="categories"> (<<---I want to get here)
        <method id="getCategoriesResource" name="GET">

And I want to get the value of resource/@path so I have the following Java code:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); // never forget this!
DocumentBuilder builder = factory.newDocumentBuilder();
// get the xml to parse from URI
Document doc = builder.parse(serviceUri + "application.wadl"); 
XPathFactory xfactory = XPathFactory.newInstance();
XPath xpath = xfactory.newXPath();
XPathExpression expression = 
        xpath.compile("/application/resources/resource/@path");
this.baseUri = (String) expression.evaluate(doc, XPathConstants.STRING);

With this XPath expression the result (baseUri) is always the empty string ("").

  • 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-27T18:55:06+00:00Added an answer on May 27, 2026 at 6:55 pm

    The nodes are not in the empty string namespace, you must specify it: /wadl:application/wadl:resources/wadl:resource/@path. Also, you should register the namespace in the XPath engine namespace context.

    This is working example:

        xpath.setNamespaceContext(new NamespaceContext()
        {
            @Override
            public String getNamespaceURI(final String prefix)
            {
                if(prefix.equals("wadl"))
                    return "http://research.sun.com/wadl/2006/10";
                else
                    return null;
            }
    
            @Override
            public String getPrefix(final String namespaceURI)
            {
                throw new UnsupportedOperationException();
            }
    
            @Override
            public Iterator getPrefixes(final String namespaceURI)
            {
                throw new UnsupportedOperationException();
            }
        });
        XPathExpression expression = xpath.compile("/wadl:application/wadl:resources/wadl:resource/@path");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML structure: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root xmlns:xsi=My Program> <NotRoot
I have following XML schema: <?xml version=1.0 encoding=UTF-8 standalone=no?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=content type=contentType/>
I have the following the layout file <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:app=http://schemas.android.com/apk/res/com.company android:layout_width=fill_parent
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
I have used urllib to get the following data: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <videos
This is my XML Document. <?xml version=1.0 encoding=UTF-8 standalone=yes?> <w:document xmlns:w=http://schemas.openxmlformats.org/wordprocessingml/2006/main> <w:body> <w:p> <!--
I have the following XML: <?xml version=1.0 encoding=UTF-8?> <gnm:Workbook xmlns:gnm=http://www.gnumeric.org/v10.dtd xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.gnumeric.org/v9.xsd> <office:document-meta xmlns:office=urn:oasis:names:tc:opendocument:xmlns:office:1.0
I have a style sheet like this <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:param
I have the following xml file: <?xml version=1.0 encoding=UTF-8 standalone=no ?> <config> <a> <b>
I have the following code. <?xml version=1.0 encoding=UTF-8 standalone=no?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML

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.