I\'m using xpath to grab information from a document, the only issue is I havn\'t been able to combine them into 1 for loop so the information displays correctly on the page. My
I couldn't resist to give this another try to apply a model on some XML source. I opted for SimpleXMLElement
for this answer. It is merely transparent and has mostly only implications on the xpath expressions. It should be possible to translate the same interface to DOMDocument
.
$unitPrototype = new XPrototype(
"//ILS_Unit[@FloorplanID='550584']/Unit",
[
'name' => 'MITS:MarketingName',
'price' => 'MITS:Information/MITS:MarketRent'
]
);
$units = new XList('http://mdoerrdev.com/xml/updates-mits.xml', $unitPrototype);
foreach ($units as $unit) {
echo
$unit->name, " ",
$unit->price, "\n";
}
The source of the used types like XPrototype
and XList
is on Github: XObjects.php.