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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:23:04+00:00 2026-06-10T00:23:04+00:00

hi guys so i have a problem with an xml, it has – before

  • 0

hi guys so i have a problem with an xml, it has – before node and i dont know how to deal with this properly with xpath, so the xml would look like this

<xml>
 <item>
 -<description>
  -<type>
   </type>
  </description>
 </item>
</xml>

so how can i navigate down to say type in xpath just before anyone wastes any time giving out the wrong answer i have tried the normal method of $xml->item->description->type this does not work in this case i dont know as its not an illegal character in the name how to deal with the – before th nodes

  • 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-10T00:23:05+00:00Added an answer on June 10, 2026 at 12:23 am

    I don’t think it’s a waste of time to point out that /xml/item/description/type does in fact work (in XPath 1.0 and 2.0 in XmlSpy).

    That said, I think that perhaps you don’t really want those ‘-‘ characters in your xml. Perhaps a better question would be “How do I strip extraneous ‘-‘ characters from xml?”

    Edit:

    Here’s some PHP adapted from the SimpleXMLElement documentation to show you that I’m not lying:

    <?php
        $string =
        "<xml>
         <item>
         -<description>
          -<type>
              Hello World!
           </type>
          </description>
         </item>
        </xml>";
    
        $xml = new SimpleXMLElement($string);
    
        $path = '/xml/item/description/type';
    
        $result = $xml->xpath('/xml/item/description/type');
    
        while(list( , $node) = each($result)) {
            echo '$path: ',$node,"\n";
        }
    ?>
    

    Outputs:

    /xml/item/description/type:
        Hello World!
    

    If you want any further help, please provide a short example that reproduces the issue.

    (Apologies if my PHP is bad, I’m a bit rusty)

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

Sidebar

Related Questions

Ok guys, I have a serious problem with this. I have a static class
hey guys having this really simple problem but cant seem to figure out have
I hope some of you guys can help me with this problem.... I have
I encounter this problem : I have a django (python) server that serve XML
Hi guys i have a problem i my code i set a datepicker with
guys. I have a strange problem. I try to write unit-tests to web-app. I
Hey guys, I have a weird problem. I have an update system that refreshes
Thus far you guys have been wildly helpful with me getting this little ditty
HI Guys, I have following problem. I'm trying to connect from my Iphone app
Hi this question or problem i have its very hard i have search and

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.