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

Class: PEAR_PackageFile_Generator_v2_XML_Util

Source Location: /PEAR-1.8.0RC1/PEAR/PackageFile/Generator/v2.php

Class Overview


utility class for working with XML documents


Author(s):

Version:

  • 0.6.0

Methods


Inherited Variables

Inherited Methods


Class Details

[line 982]
utility class for working with XML documents

customized version of XML_Util 0.6.0



[ Top ]


Method Detail

createTag   [line 1055]

string createTag( string $qname, [array $attributes = array()], [mixed $content = null], [string $namespaceUri = null], [integer $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES], [boolean $multiline = false], [string $indent = "_auto"], [string $linebreak = "\n"], [string $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML])

create a tag

This method will call PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray(), which is more flexible.

  1.  require_once 'XML/Util.php';
  2.  
  3.  // create an XML tag:
  4.  $tag PEAR_PackageFile_Generator_v2_XML_Util::createTag("myNs:myTag"array("foo" => "bar")"This is inside the tag""http://www.w3c.org/myNs#");


Parameters:

string   $qname   —  qualified tagname (including namespace)
array   $attributes   —  array containg attributes
mixed   $content   — 
string   $namespaceUri   —  URI of the namespace
integer   $replaceEntities   —  whether to replace XML special chars in content, embedd it in a CData section or none of both
boolean   $multiline   —  whether to create a multiline tag where each attribute gets written to a single line
string   $indent   —  string used to indent attributes (_auto indents attributes so they start at the same column)
string   $linebreak   —  string used for linebreaks
string   $encoding   —  encoding that should be used to translate content

[ Top ]

createTagFromArray   [line 1118]

string createTagFromArray( array $tag, [integer $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES], [boolean $multiline = false], [string $indent = "_auto"], [string $linebreak = "\n"], [ $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML])

create a tag from an array

this method awaits an array in the following format

 array(
  "qname"        => $qname         // qualified name of the tag
  "namespace"    => $namespace     // namespace prefix (optional, if qname is specified or no namespace)
  "localpart"    => $localpart,    // local part of the tagname (optional, if qname is specified)
  "attributes"   => array(),       // array containing all attributes (optional)
  "content"      => $content,      // tag content (optional)
  "namespaceUri" => $namespaceUri  // namespaceUri for the given namespace (optional)
   )

  1.  require_once 'XML/Util.php';
  2.  
  3.  $tag = array(
  4.            "qname"        => "foo:bar",
  5.            "namespaceUri" => "http://foo.com",
  6.            "attributes"   => array"key" => "value""argh" => "fruit&vegetable" ),
  7.            "content"      => "I'm inside the tag",
  8.             );
  9.  // creating a tag with qualified name and namespaceUri


Parameters:

array   $tag   —  tag definition
integer   $replaceEntities   —  whether to replace XML special chars in content, embedd it in a CData section or none of both
boolean   $multiline   —  whether to create a multiline tag where each attribute gets written to a single line
string   $indent   —  string used to indent attributes (_auto indents attributes so they start at the same column)
string   $linebreak   —  string used for linebreaks
   $encoding   — 

[ Top ]

replaceEntities   [line 1003]

string replaceEntities( string $string, [integer $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML])

replace XML entities

With the optional second parameter, you may select, which entities should be replaced.

  1.  require_once 'XML/Util.php';
  2.  
  3.  // replace XML entites:
  4.  $string PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities("This string contains < & >.");

  • Return: string with replaced chars
  • Access: public

Parameters:

string   $string   —  string where XML special chars should be replaced
integer   $replaceEntities   —  setting for entities in attribute values (one of PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML)

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:30:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.