Grima 2018-08
Whispering into Alma's ear
Classes | Functions
grima-xmlbag.php File Reference

Go to the source code of this file.

Classes

class   XMLAsArrayOfWhateversSpecifiedByXPath
 
class   XMLAsArrayOfDOMNodesSpecifiedByXPath
 
class   XMLAsArrayOfDOMNodeListsSpecifiedByXPath
 
class   XMLAsArrayOfStringsSpecifiedByXPath
 

Functions

  xml_debug ( $obj)
 
  test ()
 

Function Documentation

◆ test()

test ( )

Definition at line 191 of file grima-xmlbag.php.

191 {
192 $xml = file_get_contents("item-sample.xml");
193 $item_item_data = new XMLAsArrayOfStringsSpecifiedByXPath($xml, "/item/item_data");
194 print "EnumerationA: " . $item_item_data['enumeration_a'] . "\n\n";
195 $item_item_data['enumeration_a'] = "NOOOOOOOOO";
196 print $item_item_data->xml->saveXML();
197}

◆ xml_debug()

xml_debug (   $obj )

Definition at line 18 of file grima-xmlbag.php.

18 {
19 $retval = get_class($obj)."\n";
20 switch(true) {
21 case ($obj instanceof DOMDocument):
22 $retval .= "XPath: {$obj->getNodePath()}\n".$obj->saveXML($obj);
23 break;
24 case ($obj instanceof DOMElement):
25 $retval .= "XPath: {$obj->getNodePath()}\n".$obj->ownerDocument->saveXML($obj);
26 break;
27 case ($obj instanceof DOMAttr):
28 $retval .= "XPath: {$obj->getNodePath()}\n".$obj->ownerDocument->saveXML($obj);
29 break;
30 case ($obj instanceof DOMNodeList):
31 $retval .= "NodeList of length {$obj->length}\n";
32 print $retval;
33 for ($i = 0; $i < $obj->length; $i++) {
34 $retval .= "Item #$i, " . xml_debug($obj->item($i));
35 }
36 break;
37 default:
38 return "Instance of unknown class";
39 }
40 return $retval;
41}
xml_debug( $obj)
Definition: grima-xmlbag.php:18

References xml_debug().

Referenced by xml_debug().