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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:31:57+00:00 2026-05-10T22:31:57+00:00

A strange thing happened after a supplier changed the XML header a bit. I

  • 0

A strange thing happened after a supplier changed the XML header a bit. I used to be able to read stuff using xpath, but now I can’t even get a reply with

$xml->xpath('/'); 

They changed it from this…

<?xml version='1.0' encoding='iso-8859-1'?> <!DOCTYPE NewsML SYSTEM 'http://www.newsml.org/dl.php?fn=NewsML/1.2/specification/NewsML_1.2.dtd' [ <!ENTITY % nitf SYSTEM 'http://www.nitf.org/IPTC/NITF/3.4/specification/dtd/nitf-3-4.dtd'> %nitf; ]> <NewsML> ... 

to this:

<?xml version='1.0' encoding='iso-8859-1'?> <NewsML   xmlns='http://iptc.org/std/NewsML/2003-10-10/'   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'   xsi:schemaLocation='http://iptc.org/std/NewsML/2003-10-10/ http://www.iptc.org/std/NewsML/1.2/specification/NewsML_1.2.xsd http://iptc.org/std/NITF/2006-10-18/   http://contentdienst.pressetext.com/misc/nitf-3-4.xsd' > ... 
  • 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-10T22:31:58+00:00Added an answer on May 10, 2026 at 10:31 pm

    Most likely this is because they’ve introduced a default namespace (xmlns='http://iptc.org/std/NewsML/2003-10-10/') into their document. SimpleXML’s support for default namespaces is not very good, to put it mildly.

    Can you try to explicitly register a namespace prefix:

    $xml->registerXPathNamespace('n', 'http://iptc.org/std/NewsML/2003-10-10/'); $xml->xpath('/n:NewsML'); 

    You would have to adapt your XPath expressions to use the 'n:' prefix on every element. Here is some additional info: http://people.ischool.berkeley.edu/~felix/xml/php-and-xmlns.html.

    EDIT: As per the spec:

    The registerXPathNamespace() function creates a prefix/ns context for the next XPath query.

    This means it would have to be called before every XPath query, thus a function to wrap XPath queries would be the natural thing to do:

    function simplexml_xpath_ns($element, $xpath, $xmlns) {     foreach ($xmlns as $prefix_uri)     {         list($prefix, $uri) = explode('=', $prefix_uri, 2);         $element->registerXPathNamespace($prefix, $uri);     }     return $element->xpath($xpath); } 

    Usage:

    $xmlns = ['n=http://iptc.org/std/NewsML/2003-10-10/']; $result = simplexml_xpath_ns($xml, '/n:NewsML', $xmlns); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 82k
  • Answers 83k
  • 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 If you use Hibernate Tools to generate your code the… May 11, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer $last = count($arr_nav) - 1; foreach ($arr_nav as $i =>… May 11, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer What's the data type and purpose of columnX in the… May 11, 2026 at 4:45 pm

Related Questions

Is there a way to run a regexp-string replace on the current line in
I write a piece of code to do something->show alert1->do something->show alert2. //do something
Some of the queries I have written inside MS-Access are getting deleted automatically. And
I've been using TortoiseSVN in a Windows environment for quite some time. It seems

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.