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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:21:56+00:00 2026-05-11T14:21:56+00:00

I have this ugly XML which has alot of namespaces on it, when I

  • 0

I have this ugly XML which has alot of namespaces on it, when I try to load it with simpleXML if i indicate the first namespace I’d get an xml object ,but following tags with other namespaces would not make it to the object.

How can I parse this XML ?

<?xml version='1.0' encoding='UTF-8'?> <soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'>     <soap-env:Header>         <eb:MessageHeader xmlns:eb='http://www.ebxml.org/namespaces/messageHeader' eb:version='1.0' soap-env:mustUnderstand='1'>             <eb:From>                 <eb:PartyId eb:type='URI'>wscompany.com</eb:PartyId>             </eb:From>             <eb:To>                 <eb:PartyId eb:type='URI'>mysite.com</eb:PartyId>             </eb:To>             <eb:CPAId>something</eb:CPAId>             <eb:ConversationId>moredata.com</eb:ConversationId>             <eb:Service eb:type='compXML'>theservice</eb:Service>             <eb:Action>theaction</eb:Action>             <eb:MessageData>                 <eb:MessageId>a certain messageid</eb:MessageId>                 <eb:Timestamp>2009-04-11T18:43:58</eb:Timestamp>                 <eb:RefToMessageId>mid:areference</eb:RefToMessageId>             </eb:MessageData>         </eb:MessageHeader>         <wsse:Security xmlns:wsse='http://schemas.xmlsoap.org/ws/2002/12/secext'>             <wsse:BinarySecurityToken valueType='String' EncodingType='wsse:Base64Binary'>an impresive binary security toekn</wsse:BinarySecurityToken>         </wsse:Security>     </soap-env:Header>     <soap-env:Body>         <SessionCreateRS xmlns='http://www.opentravel.org/OTA/2002/11' version='1' status='Approved'>             <ConversationId>the goodbye token</ConversationId>         </SessionCreateRS>     </soap-env:Body> </soap-env:Envelope> 

im trying to parse it with the following code

<?php $xml = simplexml_load_string($res,NULL,NULL,'http://schemas.xmlsoap.org/soap/envelope/'); ?> 

but the $xml object would only contain the following

SimpleXMLElement Object (     [Header] => SimpleXMLElement Object         (         )      [Body] => SimpleXMLElement Object         (         )  ) 
  • 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. 2026-05-11T14:21:57+00:00Added an answer on May 11, 2026 at 2:21 pm

    I think you need to register the namespacing and access with XPath. Something like the following should get you going (I haven’t the facility to test this).

    $xml = simplexml_load_string($res, NULL, NULL, 'http://schemas.xmlsoap.org/soap/envelope/'); $xml->registerXPathNamespace('soap-env', 'http://schemas.xmlsoap.org/soap/envelope/'); $xml->registerXPathNamespace('eb', 'http://www.ebxml.org/namespaces/messageHeader'); $xml->registerXPathNamespace('wsse', 'http://schemas.xmlsoap.org/ws/2002/12/secext'); 

    Then you can do something like:

    foreach($xml->xpath('//eb:MessageHeader') as $header) {     var_export($header->xpath('//eb:CPAId')); // Should output 'something'. } 

    You may not need to register the namespacing, thinking about it, as they are alredy present in the XML. Not sure on this though, would need to test.

    Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I have written this event photography application that features a slideshow among other things.
My application supports both Oracle and MS SQL databases, with slightly different schemas having
The concept So, I've already made (upgraded actually) this website with its own Content
I would like to design a web app that allows me to sort, browse,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.