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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:39:27+00:00 2026-05-14T00:39:27+00:00

I am using php’s simple xml and xpath to parse an rdf xml file

  • 0

I am using php’s simple xml and xpath to parse an rdf xml file and am struggling to get a list of all the rdf:about values.

Any advice?

  • 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-14T00:39:27+00:00Added an answer on May 14, 2026 at 12:39 am

    There seems to be an issue when using SimpleXml with namespaced attributes prior to PHP5.3. Basically, anything with a : will be dropped when converted to an object property of a SimpleXml element. The following will do, but feels hackish to me:

    $rdf = str_replace('rdf:about', 'rdf_about', $rdf);  
    $rdf = new SimpleXMLElement($rdf);
    foreach($rdf->xpath('//@rdf_about') as $node) {
      echo $node, PHP_EOL;
    }
    

    See here:

    • http://groups.google.com/group/comp.lang.php/browse_thread/thread/d2a9b29ee21f7403/c6b24b6d398ece2c

    You could use DOM instead of SimpleXml:

    $dom = new DomDocument;
    $dom->loadXml($rdf);
    $xph = new DOMXPath($dom);
    $xph->registerNamespace('rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    foreach($xph->query('//@rdf:about') as $attribute) {
        echo $attribute->value, PHP_EOL;
    }
    

    But, I suggest using a dedicated library for this over SimpleXml or DOM:

    • http://arc.semsol.org/docs/v2/parsing
    • http://www.seasr.org/wp-content/plugins/meandre/rdfapi-php/doc/
    • http://librdf.org/raptor/
    • http://phpxmlclasses.sourceforge.net/show_doc.php?class=class_rdf_parser.html

    And here’s a blog post about the parsers:

    • http://www.wasab.dk/morten/blog/archives/2004/05/31/easy-rdf-parsing-with-php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP and MySQL I'm trying to select unique values from multiple columns in
Using PHP and MySQL in a script run on mysite1.com I'm trying to copy
Using PHP I am able to query MySQL database and see the results echo
Using PHP i want to create a picture gallery, i need a few suggestion
Using PHP, I have a query that goes through my DB looking for pending
Using PHP, I'm attempting to route email through AuthSMTP (a hosted SMTP service). The
Using PHP mysql_num_rows() returns 1 when running the query below on the table below
Using PHP 5.2.5 I was working with some DateTime objects and noticed a time
Using PHP or Python , but I'm sure the basic functions are agnostic. I
Using PHP 5.3.2, I'm having trouble with handling a request for a page whose

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.