php simplexml
im having trouble using simplexml to read an xml file that uses a namespace prefix. heres my xml
Code:<?xml version="1.0" encoding="UTF-8"?>
<mu:mash xmlns:mu="#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="#" title="m3net" author=".clicky">
<mu:img id="test" src="http://a345.ac-images.myspacecdn.com/images01/64/m_d347d48c72b56a7e06decb94da2f84c8.jpg"/>
</mu:mash>
and heres my php
PHP:<?php
class XMLParser {
var $xml;
var $currentTag;
function XMLParser($str) {
$this->xml = simplexml_load_file($str);
echo("Mashup: ".$this->xml['title']." by ".$this->xml['author']."<br/><br/>");
}
function readChildNodes() {
echo("hello");
foreach ($this->xml->children() as $item) {
echo($item['src']);
}
}
}
$xml_p = new XMLParser(url);
$xml_p->readChildNodes();
?>
it works fine upto the readChildNodes() function. this only works when i remove the mu: namespace prefix from the <img> tag. any ideas?
Last edited by sapphire, June 9th, 2007 10:43 PM (Edited 1 times)
