XML_Util
[ class tree: XML_Util ] [ index: XML_Util ] [ all elements ]

Source for file example2.php

Documentation is available at example2.php

  1. <?PHP
  2.     require_once 'XML/Util.php';
  3.  
  4.     /**
  5.     * creating a start element
  6.     */
  7.     print "creating a start element:<br>";
  8.     print htmlentities(XML_Util::createStartElement("myNs:myTag"array("foo" => "bar")"http://www.w3c.org/myNs#"));
  9.     print "\n<br><br>\n";
  10.  
  11.  
  12.     /**
  13.     * creating a start element
  14.     */
  15.     print "creating a start element:<br>";
  16.     print htmlentities(XML_Util::createStartElement("myTag"array()"http://www.w3c.org/myNs#"));
  17.     print "\n<br><br>\n";
  18.  
  19.     /**
  20.     * creating a start element
  21.     */
  22.     print "creating a start element:<br>";
  23.     print "<pre>";
  24.     print htmlentities(XML_Util::createStartElement("myTag"array"foo" => "bar""argh" => "tomato" )"http://www.w3c.org/myNs#"true));
  25.     print "</pre>";
  26.     print "\n<br><br>\n";
  27.  
  28.  
  29.     /**
  30.     * creating an end element
  31.     */
  32.     print "creating an end element:<br>";
  33.     print htmlentities(XML_Util::createEndElement("myNs:myTag"));
  34.     print "\n<br><br>\n";
  35.  
  36.     /**
  37.     * creating a CData section
  38.     */
  39.     print "creating a CData section:<br>";
  40.     print htmlentities(XML_Util::createCDataSection("I am content."));
  41.     print "\n<br><br>\n";
  42.  
  43.     /**
  44.     * creating a comment
  45.     */
  46.     print "creating a comment:<br>";
  47.     print htmlentities(XML_Util::createComment("I am a comment."));
  48.     print "\n<br><br>\n";
  49.  
  50.     /**
  51.     * creating an XML tag with multiline mode
  52.     */
  53.     $tag = array(
  54.                   "qname"        => "foo:bar",
  55.                   "namespaceUri" => "http://foo.com",
  56.                   "attributes"   => array"key" => "value""argh" => "fruit&vegetable" ),
  57.                   "content"      => "I'm inside the tag & contain dangerous chars"
  58.                 );
  59.  
  60.     print "creating a tag with qualified name and namespaceUri:<br>\n";
  61.     print "<pre>";
  62.     print "</pre>";
  63.     print "\n<br><br>\n";
  64.  
  65.     /**
  66.     * create an attribute string without replacing the entities
  67.     */
  68.     $atts = array'series' => 'Starsky &amp; Hutch''channel' => 'ABC' );
  69.     print "creating a attribute string, entities in values already had been replaced:<br>";
  70.     print htmlentities(XML_Util::attributesToString($attstruefalsefalsefalseXML_UTIL_ENTITIES_NONE));
  71.     print "\n<br><br>\n";
  72.  
  73.     /**
  74.     * using the array-syntax for attributesToString()
  75.     */
  76.     $atts = array'series' => 'Starsky &amp; Hutch''channel' => 'ABC' );
  77.     print "using the array-syntax for attributesToString()<br>";
  78.     print htmlentities(XML_Util::attributesToString($attsarray('entities' => XML_UTIL_ENTITIES_NONE)));
  79.     print "\n<br><br>\n";
  80.  
  81.  
  82. ?>

Documentation generated on Mon, 11 Mar 2019 10:17:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.