I\'ve been trying to parse a very large XML file with PHP and XMLReader, but can\'t seem to get the results I am looking for. Basically, I\'m searching a ton of information
Edit: Oh you want to return the parent chunk? One moment.
Here's an example to pull out all of the postalCodes into an array.
http://codepad.org/kHss4MdV
Grande Gables at The Terrace
Grande Communications
635
11111
22222
33333
78746
Austin
002
003
Thorndale
Milam
TX
Thrall
Williamson
TX
';
$dom = new DOMDocument();
$dom->loadXML($string);
$xpath = new DOMXPath($dom);
$elements= $xpath->query('//lineups/headend/postalCodes/*[text()=78746]');
if (!is_null($elements)) {
foreach ($elements as $element) {
echo "
[". $element->nodeName. "]";
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
Outputs:
[postalCode]78746