Answer the question
In order to leave comments, you need to log in
SimpleXML, namespaces and tag attributes?
I'm trying to parse data about a LJ user. Read resource exampleusername.livejournal.com/data/foaf , load it into SimpleXML:
$input_xml = simplexml_load_string(file_get_contents('http://exampleusername.livejournal.com/data/foaf'));
$person = $input_xml->children('http://xmlns.com/foaf/0.1/');
echo $person->Person->name.'<br/>';
echo $person->Person->dateOfBirth;
$blog = $person->Person->weblog->children('http://www.livejournal.org/rss/lj/1.0/');
object(SimpleXMLElement)#4 (1) {
["@attributes"]=>
array(2) {
["dateCreated"]=>
string(19) "2008-12-15T18:00:10"
["dateLastUpdated"]=>
string(19) "2012-03-16T09:49:22"
}
}
Answer the question
In order to leave comments, you need to log in
get this tag in $tag then try like this:
$attr = $tag->attributes("lj", 1);
$dc = $attr["dateCreated"];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question