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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:11+00:00 2026-05-23T07:44:11+00:00

All, Trying to parse this SOAP response but xpath() is returning Debug Warning: SimpleXMLElement::xpath()

  • 0

All,

Trying to parse this SOAP response but xpath() is returning

Debug Warning: SimpleXMLElement::xpath() Undefined namespace prefix
Debug Warning: SimpleXMLElement::xpath() evaluation failed

 $result = '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    <env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <v4:TrackReply xmlns:v4="http://fedex.com/ws/track/v4">
            ...
        </v4:TrackReply>
    </env:Body>
</soapenv:Envelope>';


 $xml = simplexml_load_string($result,NULL,NULL,'http://schemas.xmlsoap.org/soap/envelope/');



foreach($xml->xpath('env:Body') as $body){

    //drill down here...
}
  • 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-23T07:44:12+00:00Added an answer on May 23, 2026 at 7:44 am

    Try registering the namespace to ‘env’

    $xml->registerXPathNamespace('env', 'http://schemas.xmlsoap.org/soap/envelope/');

    Edit
    This code sets the namespace of child elements within body

    $bodies = $xml->xpath('env:Body');
    foreach($bodies as $body){
        $reply = $body->children('v4', TRUE)->TrackReply;
        var_dump($reply);
    }
    

    Alternatively, you can get an element like TrackReply directly with:

    $xml->registerXPathNamespace('env', 'http://schemas.xmlsoap.org/soap/envelope/');
    $xml->registerXPathNamespace('v4', 'http://fedex.com/ws/track/v4');
    var_dump($xml->xpath('env:Body/v4:TrackReply'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent the last few days trying to parse a SOAP response but
I'm trying to parse this xml input using the bash utility xpath : <?xml
I may be way off base, but I've been trying all afternoon to run
I have been trying for days to figure out how to parse this JSON
Dear All, I am trying to parse the following HTML fragment, and I would
I am trying to parse through all elements in a single radio button (or
I am trying to parse my URL into different parts using this RegExp: ([\w\\.-]*)
This is the log I am trying to parse: 06:27:54 /data/noc/startup/startup_ptf_pats.sh startup initiated by
This is an example of a complex tab separated file I'm trying to parse
http://pastebin.com/rXbeKqAa Hi all I have been trying to parse the above JSON into a

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.