PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to use the javascript XMLHTTP object in order to parse XML data. This procedure works fine when I have a static XML document. However, I need to use a dynamically created XML file created through PHP, such as the following:
class Articles extends DomDocument {
function __construct() {
//has to be called!
parent::__construct();
}
function addArticle($name, $id) {
$item = $this->createElement("university");
$attr1 = $this->createAttribute("name");
$attr1text = $this->createTextNode($name);
$attr1->appendChild($attr1text);
$attr2 = $this->createAttribute("id");
$attr2text = $this->createTextNode($id);
$attr2->appendChild($attr2text);
$item->appendChild($attr1);
$item->appendChild($attr2);
$this->documentElement->appendChild($item);
}
}
$dom = new Articles();
$titlespace = $dom->createElement("schools");
$dom->appendChild($titlespace);
$dom->addArticle('test article','article id');
echo $dom->saveXML();
When I view this file, it correctly outputs the XML. However, I am unable to parse it using the XMLHTTP object. Is a php dynamically generated XML file somehow different from a static xml file?
jbkielis wrote:wow...I should have stopped banging my head against a wall and asked on this forum earlier. Worked like a charm. thanks.
Not just any forum. THIS forum. Where geniuses of the likes of timvw can assist you.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.