Class: XML_Util2
Source Location: /XML_Util2-0.2.0/XML/Util2.php
utility class for working with XML documents
Author(s):
Version:
Copyright:
- 2003-2008 Stephan Schmidt <schst@php.net>
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
apiVersion [line 135]
attributesToString [line 395]
string attributesToString(
array
$attributes, [bool|array
$sort = true], [bool
$multiline = false], [string
$indent = ' '], [string
$linebreak = "\n"], [int
$entities = XML_Util2::ENTITIES_XML])
|
|
create string representation of an attribute list require_once 'XML/Util2.php';
// build an attribute string
$att = array(
'foo' => 'bar',
'argh' => 'tomato'
);
Parameters:
collapseEmptyTags [line 465]
string collapseEmptyTags(
string
$xml, [int
$mode = XML_Util2::COLLAPSE_ALL])
|
|
Collapses empty tags.
Parameters:
createCDataSection [line 815]
string createCDataSection(
string
$data)
|
|
create a CData section require_once 'XML/Util2.php';
// create a CData section
Parameters:
createComment [line 792]
string createComment(
string
$content)
|
|
create an XML comment require_once 'XML/Util2.php';
// create an XML start element:
Parameters:
createEndElement [line 769]
string createEndElement(
string
$qname)
|
|
create an end element require_once 'XML/Util2.php';
// create an XML start element:
Parameters:
createStartElement [line 714]
string createStartElement(
string
$qname, [array
$attributes = array()], [string
$namespaceUri = null], [bool
$multiline = false], [string
$indent = '_auto'], [string
$linebreak = "\n"], [bool
$sortAttributes = true])
|
|
create a start element require_once 'XML/Util2.php';
// create an XML start element:
array('foo' => 'bar') ,'http://www.w3c.org/myNs#');
Parameters:
createTag [line 516]
string createTag(
string
$qname, [array
$attributes = array()], [mixed
$content = null], [string
$namespaceUri = null], [int
$replaceEntities = XML_Util2::REPLACE_ENTITIES], [bool
$multiline = false], [string
$indent = '_auto'], [string
$linebreak = "\n"], [bool
$sortAttributes = true])
|
|
create a tag This method will call XML_Util2::createTagFromArray(), which is more flexible. require_once 'XML/Util2.php';
// create an XML tag:
array('foo' => 'bar'),
'This is inside the tag',
'http://www.w3c.org/myNs#');
Parameters:
createTagFromArray [line 600]
string createTagFromArray(
array
$tag, [int
$replaceEntities = XML_Util2::REPLACE_ENTITIES], [bool
$multiline = false], [string
$indent = '_auto'], [string
$linebreak = "\n"], [bool
$sortAttributes = true])
|
|
create a tag from an array this method awaits an array in the following format array(
// qualified name of the tag
'qname' => $qname
// namespace prefix (optional, if qname is specified or no namespace)
'namespace' => $namespace
// local part of the tagname (optional, if qname is specified)
'localpart' => $localpart,
// array containing all attributes (optional)
'attributes' => array(),
// tag content (optional)
'content' => $content,
// namespaceUri for the given namespace (optional)
'namespaceUri' => $namespaceUri
) require_once 'XML/Util2.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 338]
string getDocTypeDeclaration(
string
$root, [string
$uri = null], [string
$internalDtd = null])
|
|
build a document type declaration require_once 'XML/Util2.php';
// get a doctype declaration:
Parameters:
getXMLDeclaration [line 297]
string getXMLDeclaration(
[string
$version = '1.0'], [string
$encoding = null], [bool
$standalone = null])
|
|
build an xml declaration require_once 'XML/Util2.php';
// get an XML declaration:
Parameters:
isValidName [line 890]
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/Util2.php';
// verify tag name
if (is_a($result, 'PEAR_Error')) {
print 'Invalid XML name: ' . $result->getMessage();
}
Parameters:
raiseError [line 920]
PEAR_Error raiseError(
string
$msg, int
$code)
|
|
Parameters:
replaceEntities [line 183]
string replaceEntities(
string
$string, [int
$replaceEntities = XML_Util2::ENTITIES_XML], [string
$encoding = 'ISO-8859-1'])
|
|
replace XML entities With the optional second parameter, you may select, which entities should be replaced. require_once 'XML/Util2.php';
// replace XML entites:
With the optional third parameter, you may pass the character encoding require_once 'XML/Util2.php';
// replace XML entites in UTF-8:
'This string contains < & > as well as ä, ö, ß, à and ê',
'UTF-8'
);
Parameters:
reverseEntities [line 252]
string reverseEntities(
string
$string, [int
$replaceEntities = XML_Util2::ENTITIES_XML], [string
$encoding = 'ISO-8859-1'])
|
|
reverse XML entities With the optional second parameter, you may select, which entities should be reversed. require_once 'XML/Util2.php';
// reverse XML entites:
With the optional third parameter, you may pass the character encoding require_once 'XML/Util2.php';
// reverse XML entites in UTF-8:
'This string contains < & > as well as'
. ' ä, ö, ß, à and ê',
'UTF-8'
);
Parameters:
splitQualifiedName [line 847]
array splitQualifiedName(
string
$qname, [string
$defaultNs = null])
|
|
split qualified name and return namespace and local part require_once 'XML/Util2.php';
// split qualified tag
the returned array will contain two elements:
array(
'namespace' => 'xslt',
'localPart' => 'stylesheet'
);
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:57:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|