Hi:
I'm totally confused and lost on parsing XML! The fact that my client's XML formatting keeps changing doesn't help either!
Anyways, I got an XML file, I need to query over it and display the relevant data based on the passed value.
XML file is:
<ls id="123" allocMethod="static" bootOptions="empty" bootPgIdent="0" bootStatus="completed" />
<ls id="124" allocMethod="static" bootOptions="empty" bootPgIdent="20" bootStatus="failed" />
<ls id="376" allocMethod="dynamic" bootOptions="empty" bootPgIdent="30" bootStatus="failed" />
I need to :
-
Query over the file, list all the attributes in the html table format
-
Clicking on any of the id's would take you to a new page , which will display all the attributes of that ls only.
I could do this easily with mysql, however my XML parsing is not so strong!
I know I have to use simplexml_load_file('ls.xml'); to load the file. And I have to use xpath to query the file.
I was using this code before, but that queries the elements and not the attributes:
$dom = new DomDocument();
$dom->load("ls.xml");
$xp = new domxpath($dom);
$id = $xp->query("/listResponse/ls[ident=$_GET[id]]");
foreach ($id as $node) {
print $node->textContent . " ";
}
This code was helpful when the client had all the data as elements, however they've changed their formatting and added bunch of attributes to the tag, as shown. They will not change their formatting.
Any help is greatly appreciated, please let me know if I need to provide more info.
thanks in advance
Kamy