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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:09:24+00:00 2026-06-03T16:09:24+00:00

I’m new to working with xml and xsd stuff. I’m trying to create a

  • 0

I’m new to working with xml and xsd stuff. I’m trying to create a web service client using Guzzle:

http://guzzlephp.org/index.html

I was able to create a very basic client and 1 command following this tutorial:

http://guzzlephp.org/tour/building_services.html

The issue I have is how get the returned XML into a more useful format. The web service I’m using (and its documentation and xsd) can be found here:

http://www.epo.org/searching/free/ops.html

I get a SimpleXMLElement. Assume following content of the XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/2.6.2/style/exchange.xsl"?>
<ops:world-patent-data xmlns:ops="http://ops.epo.org" xmlns="http://www.epo.org/exchange" xmlns:ccd="http://www.epo.org/ccd" xmlns:xlink="http://www.w3.org/1999/xlink">
    <ops:meta name="elapsed-time" value="30"/>
    <exchange-documents>
        <exchange-document system="ops.epo.org" family-id="19768124" country="EP" doc-number="1000000" kind="A1">
            <bibliographic-data>
                <publication-reference>
                    <document-id document-id-type="docdb">
                        <country>EP</country>
                        <doc-number>1000000</doc-number>
                        <kind>A1</kind>
                        <date>20000517</date>
                    </document-id>
                    <document-id document-id-type="epodoc">
                        <doc-number>EP1000000</doc-number>
                        <date>20000517</date>
                    </document-id>
                </publication-reference>
                <!-- a lot of content snipped -->
            </bibliographic-data>
        </exchange-document>        
    </exchange-documents>
</ops:world-patent-data>

How can I as very simple example extract the doc-number (on Line 11 of the XML above)?

I tried:

$xpath = '/ops:world-patent-data/exchange-documents/exchange-document/bibliographic-data/publication-reference/document-id/doc-number';
$data = $result->xpath($xpath);

and variations of it but $data is always and empty array.

  • 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-03T16:09:26+00:00Added an answer on June 3, 2026 at 4:09 pm

    I believe that your problem is rather related to the use of namespace prefixes. What I would do (as a best practice as well) is to make sure I register my own prefixes and namespaces before writing my xpath. This way, I would be using the prefixes as controlled by me.

    PHP has a weird (in my opinion) way of dealing with this, since it allows a “default” way i.e. is trying to resolve by itself the prefixes. In your case, the tags in this path exchange-documents/exchange-document/bibliographic-data/publication-reference/document-id/doc-number actually are qualified, due to xmlns="http://www.epo.org/exchange". If you would register a prefix for this namespace, and use it in your XPath, I am sure your stuff will work.

    Take a look at this PHP help topic to understand more about it…

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

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.