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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:41:54+00:00 2026-06-18T22:41:54+00:00

I have a file that looks like this: <ExternalPage about=http://animation.about.com/> <d:Title>About.com: Animation Guide</d:Title> <d:Description>Keep

  • 0

I have a file that looks like this:

    <ExternalPage about="http://animation.about.com/">
       <d:Title>About.com: Animation Guide</d:Title>
       <d:Description>Keep up with developments in online animation for all skill levels.     Download tools, and seek inspiration from online work.</d:Description>
       <topic>Top/Arts/Animation</topic>
    </ExternalPage>
    <ExternalPage about="http://www.toonhound.com/">
       <d:Title>Toonhound</d:Title>
       <d:Description>British cartoon, animation and comic strip creations - links, reviews  and news from the UK.</d:Description>
       <topic>Top/Arts/Animation</topic>
    </ExternalPage>

etc.

I’m trying to get the “about” url, as well as the nested title and description. I’ve tried the following code, but all I get is a bunch of dashes…

$reader = new XMLReader();

if (!$reader->open("dbpedia/links/xml.xml")) {
die("Failed to open 'xml.xml'");
}
$num=0;
while($reader->read() && $num<200) {
if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'ExternalPage') {
$url = $reader->getAttribute('about');

while ($xml->nodeType !== XMLReader::END_ELEMENT ){
$reader->read();

 if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'd:Title') {
 $title=$xmlReader->value;
 }
elseif ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'd:Description') {
$desc=$xmlReader->value;
}
}

}
$num++;echo $url."-".$title."-".$desc."<br />";
}
$reader->close();

I’m new at xmlreader, so I’d appreciate it if someone can figure out what I’m doing wrong.

Note: I’m using xmlreader because the file is a huge one (millions of lines).

EDIT: The beginning of the file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns:r="http://www.w3.org/TR/RDF/" xmlns:d="http://purl.org/dc/elements/1.0/"       xmlns="http://dmoz.org/rdf/">
  <!-- Generated at 2013-02-10 00:03:45 EST from DMOZ 2.0 -->
  <Topic r:id="">
<catid>1</catid>
  </Topic>
<Topic r:id="Top/Arts">
    <catid>381773</catid>
  </Topic>
  <Topic r:id="Top/Arts/Animation">
  <catid>423945</catid>
<link1 r:resource="http://www.awn.com/"></link1>
<link r:resource="http://animation.about.com/"></link>
<link r:resource="http://www.toonhound.com/"></link>
<link r:resource="http://enculturation.gmu.edu/2_1/pisters.html"></link>
<link r:resource="http://www.digitalmediafx.com/Features/animationhistory.html"></link>
<link r:resource="http://www.spark-online.com/august00/media/romano.html"></link>
<link r:resource="http://www.animated-divots.net/"></link>
</Topic>
<ExternalPage about="http://www.awn.com/">
<d:Title>Animation World Network</d:Title>
<d:Description>Provides information resources to the international animation community. Features include searchable database archives, monthly magazine, web animation guide, the Animation Village, discussion forums and other useful resources.</d:Description>
<priority>1</priority>
<topic>Top/Arts/Animation</topic>
</ExternalPage>

etc

  • 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-18T22:41:56+00:00Added an answer on June 18, 2026 at 10:41 pm

    It’ll take time and proper debugging to come up with working pure XMLReader code. Meanwhile try this hybrid method:

    $xmlR = new XMLReader;
    $xmlR->open('dbpedia/links/xml.xml');
    
    //Skip until <ExternalPage> node
    while ($xmlR->read() && $xmlR->name !== 'ExternalPage');
    
    $loadedNS_f = false;
    while ($xmlR->name === 'ExternalPage')
    {
        //Read the entire parent tag with children
        $sxmlNode = new SimpleXMLElement($xmlR->readOuterXML());
    
        //collect all namespaces in node recursively once; assuming all nodes are similar
        if (!$loadedNS_f) {
            $tagNS = $sxmlNode->getNamespaces(true);
            $loadedNS_f = true; 
        }
        $URL = (string) $sxmlNode['about'];
        $dNS = $sxmlNode->children($tagNS['d']);
        $Title = (string) $dNS->Title;
        $Desc = (string) $dNS->Description;
        $Topic = (string)$sxmlNode->topic;
    
        var_dump($URL, $Title, $Desc, $Topic);
    
        // Jump to next <ExternalPage> tag
        $xmlR->next('ExternalPage');
    }
    
    $xmlR->close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like this: <rss> <channel> <title>title</title> <link>link</link> <description>description</description>
I have an XML file that looks like this: <zoo xmlns="http://myurl.com/wsdl/myservice"> <animal>elephant</animal> <exhibit> <animal>walrus</animal>
I have a file that is about 100Mb that looks like this: #meta data
I have an XML file that looks like this <library> <book> <title>Title</title> <author>author</author> <price>20</price>
I have a text file that looks like this: [22/Nov/2011 12:57:58] GET /media/js/jquery-1.4.3.min.js HTTP/1.1
I have a file that contain lines that looks like this: >AF001546_1 [88 -
I have a file that contain list of numbers that looks like this: 10^-92
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have a text file that looks like this. A 102 B 456 C
I have a file structure that looks like this ./501.res/1.bin ./503.res/1.bin ./503.res/2.bin ./504.res/1.bin and

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.