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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:06:52+00:00 2026-05-21T02:06:52+00:00

I am trying to get to a part in an xml response, without following

  • 0

I am trying to get to a part in an xml response, without following the whole path. Now I know that xpath has search abilities, but somehow I dont understand it… 🙁

The XML i am parsing is this:

<?xml version="1.0" encoding="utf-8"?>
<soapEnvelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <envHeader xmlns:env="http://www.w3.org/2003/05/soap-envelope">
        <wsaAction>http://www.rechtspraak.nl/namespaces/cir01/searchUndertakingResponse</wsaAction>
        <wsaMessageID>urn:uuid:11f7d4cd-2280-4298-85eb-dadf5bd743f1</wsaMessageID>
        <wsaRelatesTo>urn:uuid:59630fbd-b990-4020-9c1c-822c58186d96</wsaRelatesTo>
        <wsaTo>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsaTo>
        <wsseSecurity>
            <wsuTimestamp wsu:Id="Timestamp-df25f141-fed2-47ed-967e-93cd04d1c8f2">
                <wsuCreated>2011-04-02T06:52:52Z</wsuCreated>
                <wsuExpires>2011-04-02T06:57:52Z</wsuExpires>
            </wsuTimestamp>
        </wsseSecurity>
    </envHeader>
    <soapBody>
        <searchUndertakingResponse xmlns="http://www.rechtspraak.nl/namespaces/cir01"><searchUndertakingResult>
                <publicatieLijst xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" extractiedatum="2011-04-02T08:52:51" xmlns="http://www.rechtspraak.nl/namespaces/inspubber01">
                    <publicatieKenmerk>sgr.10.787.F.1300.1.10</publicatieKenmerk>
                    <publicatieKenmerk>utr.10.585.F.1300.1.10</publicatieKenmerk>
                </publicatieLijst>
            </searchUndertakingResult>
        </searchUndertakingResponse>
    </soapBody>
</soapEnvelope>

And I am looking for these values: <publicatieKenmerk>sgr.10.787.F.1300.1.10</publicatieKenmerk> <publicatieKenmerk>utr.10.585.F.1300.1.10</publicatieKenmerk>

Now this works:

$lijst = $results->soapBody->searchUndertakingResponse->searchUndertakingResult->publicatieLijst->publicatieKenmerk;
    foreach ($lijst AS $kenmerk) {
        echo $kenmerk."<BR>";
    }

But I dont want to use this, as I need to be flexible for other results. and cannot rely on
searchUndertakingResponse->searchUndertakingResult

So I was hoping to use xpath to get there, but this doesnt work:

 $lijst = $results->xpath('//publicatieKenmerk');
    foreach($lijst as $kenmerk) {
        echo $kenmerk."<br />";
    }

But I thought relative would work as well… any ideas?

  • 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-21T02:06:53+00:00Added an answer on May 21, 2026 at 2:06 am

    You’ll notice that your <publicatieLijst> node has a default namespace set: xmlns="http://www.rechtspraak.nl/namespaces/inspubber01" which means that <publicatieKenmerk> exists that namespace. That’s why //publicatieKenmerk won’t find it, you have to search in the right namespace.

    For that, you can register the namespace with your own prefix and use that prefix in the following XPath query, like this:

    $soapEnvelope = simplexml_load_string($xml);
    
    $soapEnvelope->registerXPathNamespace(
        'inspubber01',
        'http://www.rechtspraak.nl/namespaces/inspubber01'
    );
    
    foreach ($soapEnvelope->xpath('//inspubber01:publicatieKenmerk') as $publicatieKenmerk)
    {
        echo $publicatieKenmerk, "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get XPath to return an attribute value yet first search for
im trying to get the integer value from the following xml structure (its only
I am trying to get mid part of string. My table is like below
I'm trying to get some sensible positioning of my radiobuttons which are part of
I'm trying to get my commit-build.bat to execute other .BAT files as part of
I'm trying to get googletest to run on my c++ project, and part of
Trying to get comfortable with jQuery and I have encountered some sample code that
Problem I have a YQL query result that I'm trying to get converted and
Good day! I am trying to disable access on pages that are not part
I got an interceptor that I'm trying to get to output a stream when

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.