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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:51:21+00:00 2026-05-16T20:51:21+00:00

I have an xml: <Customer id=> <Name /> <Address /> </Customer> I would like

  • 0

I have an xml:

<Customer id="">
 <Name />
 <Address />
</Customer>

I would like to select ONLY a root node with its attributes without its child nodes:

<Customer id=""/ >

Is such thing possible with XPath?

  • 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-16T20:51:21+00:00Added an answer on May 16, 2026 at 8:51 pm

    No, this is not possible in XPath.

    You can’t select the node without its children, because without its children it would be a different node, hence you would not be selecting a node from the original document.

    To create the output you want you need to use a language which allows you to create new nodes, so you can’t do it in XPath. You can use XQuery to create new nodes, this should work:

    element {fn:node-name(/*)} {/*/@*}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file like this: <result> <customer> <id>1</id> <name>A</name> </customer> <customer> <id>2</id>
I have a xml doxument that looks like this: <create> <customers> <customer> <first-name>foo</first-name> <last-name>bar</last-name>
i have one xml like, Declare @xmldata xml; set @xmldata =' <Customers> <Id>1</Id> <Name>foo</Name>
I have XML that looks like this: <Parameter Name=parameter name Value=parameter value /> which
I have the following magento XML code: <action method=addLink translate=label module=customer><name>myorders</name><path>chepri/myorders/customer</path><label>Standing Orders</label></action> I was
I have the following XML file loaded into php simplexml. <adf> <prospect> <customer> <name
I have a 3-leveled hierarchy of entities: Customer-Order-Line, which I would like to retrieve
I have a list of name/value pairs that I would like to map into
I have this XML <?xml version=1.0 encoding=utf-8?> <Customers> <Customer Id=1> <Name>rtertr</Name> <DOB>2010-12-12T00:00:00</DOB> <EMail>werer@test.com</EMail> </Customer>
I have XML in the form: <Books> <Book> <Name>Lord of the Rings</Name> </Book> <Book>

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.