Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class XMLStuff
- {
- function get_xPath($xmlFileName = 'news.xml')
- {
- $xmlDocument = new DOMDocument();
- // Load the XML document
- $xmlDocument->load($xmlFileName);
- $xPath = new DOMXPath($xmlDocument);
- return $xPath;
- }
- function xml2array($xmlObject, $out = array())
- {
- foreach ((array)$xmlObject as $index => $node)
- $out[$index] = (is_object($node)) ? xml2array($node) : $node;
- return $out;
- }
- function setQuery($xmlFileName = 'news.xml'){
- $xPathQuery = "/articles/article";
- // Execute the query
- $queryNodes = $this->get_xPath($xmlFileName)->query($xPathQuery);
- return $queryNodes;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement