Class: XML_Util
Source Location: /PEAR-1.4.3/PEAR/PackageFile/Generator/v2.php
utility class for working with XML documents
Author(s):
Version:
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
apiVersion [line 966]
attributesToString [line 1119]
string attributesToString(
array
$attributes, [boolean|array
$sort = true], [boolean
$multiline = false], [string
$indent = ' '], [string
$linebreak = "\n"], [integer
$entities = XML_UTIL_ENTITIES_XML])
|
|
create string representation of an attribute list
require_once 'XML/Util.php';
// build an attribute string
$att = array(
"foo" => "bar",
"argh" => "tomato"
);
Parameters:
createCDataSection [line 1437]
string createCDataSection(
string
$data)
|
|
create a CData section
require_once 'XML/Util.php';
// create a CData section
Parameters:
createComment [line 1416]
string createComment(
string
$content)
|
|
create an XML comment
require_once 'XML/Util.php';
// create an XML start element:
Parameters:
createEndElement [line 1395]
string createEndElement(
string
$qname)
|
|
create an end element
require_once 'XML/Util.php';
// create an XML start element:
Parameters:
createStartElement [line 1345]
string createStartElement(
string
$qname, [array
$attributes = array()], [string
$namespaceUri = null], [boolean
$multiline = false], [string
$indent = '_auto'], [string
$linebreak = "\n"])
|
|
create a start element
require_once 'XML/Util.php';
// create an XML start element:
Parameters:
createTag [line 1201]
string createTag(
string
$qname, [array
$attributes = array()], [mixed
$content = null], [string
$namespaceUri = null], [integer
$replaceEntities = XML_UTIL_REPLACE_ENTITIES], [boolean
$multiline = false], [string
$indent = "_auto"], [string
$linebreak = "\n"], [string
$encoding = XML_UTIL_ENTITIES_XML])
|
|
create a tag This method will call XML_Util::createTagFromArray(), which is more flexible.
require_once 'XML/Util.php';
// create an XML tag:
$tag = XML_Util::createTag("myNs:myTag", array ("foo" => "bar"), "This is inside the tag", "http://www.w3c.org/myNs#");
Parameters:
createTagFromArray [line 1260]
string createTagFromArray(
array
$tag, [integer
$replaceEntities = XML_UTIL_REPLACE_ENTITIES], [boolean
$multiline = false], [string
$indent = "_auto"], [string
$linebreak = "\n"], [
$encoding = 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)
)
require_once 'XML/Util.php';
$tag = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
// creating a tag with qualified name and namespaceUri
Parameters:
getDocTypeDeclaration [line 1075]
string getDocTypeDeclaration(
string
$root, [string
$uri = null], [string
$internalDtd = null])
|
|
build a document type declaration
require_once 'XML/Util.php';
// get a doctype declaration:
Parameters:
getXMLDeclaration [line 1040]
string getXMLDeclaration(
[string
$version = "1.0"], [string
$encoding = null], [
$standalone = null], boolean
$standAlone)
|
|
build an xml declaration
require_once 'XML/Util.php';
// get an XML declaration:
Parameters:
isValidName [line 1506]
mixed isValidName(
string
$string)
|
|
check, whether string is valid XML name XML names are used for tagname, attribute names and various other, lesser known entities. An XML name may only consist of alphanumeric characters, dashes, undescores and periods, and has to start with a letter or an underscore.
require_once 'XML/Util.php';
// verify tag name
print "Invalid XML name: " . $result->getMessage();
}
Parameters:
raiseError [line 1532]
object PEAR_Error raiseError(
string
$msg, integer
$code)
|
|
replacement for XML_Util::raiseError Avoids the necessity to always require PEAR.php
Parameters:
replaceEntities [line 990]
string replaceEntities(
string
$string, [integer
$replaceEntities = XML_UTIL_ENTITIES_XML])
|
|
replace XML entities With the optional second parameter, you may select, which entities should be replaced.
require_once 'XML/Util.php';
// replace XML entites:
Parameters:
splitQualifiedName [line 1465]
array splitQualifiedName(
string
$qname, [string
$defaultNs = null])
|
|
split qualified name and return namespace and local part
require_once 'XML/Util.php';
// split qualified tag
the returned array will contain two elements: array(
"namespace" => "xslt",
"localPart" => "stylesheet"
);
Parameters:
Documentation generated on Mon, 11 Mar 2019 14:10:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|