Quote:
|
Originally Posted by kpkortekaas
checking the unrest at all ports is kind of a pain as it takes all the information about all the ports. it'd require a bit of parsing to format correctly.
|
I use SimpleXML and XPath in PHP (5 and higher only) to get at the specific bits of data I want, and that is a
huge help. I'll have some full sample code to show how that works soon, but whatever you're developing in, you should see if there's XPath support.
Non-programmers, feel free to cover your eyes right about... NOW.
For example, getting just the resource list for a given port is (again, PHP):
Code:
$xml = simplexml_load_file('/path/to/cached.xml');
$resourceNodes = $xml->xpath("/PortList/Port[@name='CatIsl']/resources/e");
Then you can just step through the nodes and get their info out of them.
The XPath (and interesting) bit is just:
Code:
/PortList/Port[@name='CatIsl']/resources/e]
That says, "Hey, go into the XML and grab the
e elements inside the
resources element inside the
Port element with a
name parameter with value
CatIsl inside the global
PortList element". Et voila, you've grabbed all the resources associated with the given port.
It's a bit arcane at first, but once you get the hang of it, it can really help dig into simple, structured data with (reasonably) known values.