Documentation

XMLReader

XML Reader wrapper

Tags
since
0.2.1

Table of Contents

$dom  : DOMDocument
DOMDocument object
$xpath  : DOMXpath
DOMXpath object
countElements()  : int
Count elements
elementExists()  : bool
Element exists
getAttribute()  : string|null
Get element attribute
getDomFromString()  : DOMDocument
Get DOMDocument from content string
getDomFromZip()  : DOMDocument|false
Get DOMDocument from ZipArchive
getElement()  : DOMElement|null
Get element
getElements()  : DOMNodeList
Get elements
getValue()  : string|null
Get element value
registerNamespace()  : bool
Registers the namespace with the DOMXPath object

Properties

$dom

DOMDocument object

private DOMDocument $dom = null

$xpath

DOMXpath object

private DOMXpath $xpath = null

Methods

countElements()

Count elements

public countElements(string $path[, DOMElement $contextNode = null ]) : int
Parameters
$path : string
$contextNode : DOMElement = null
Return values
int

elementExists()

Element exists

public elementExists(string $path[, DOMElement $contextNode = null ]) : bool
Parameters
$path : string
$contextNode : DOMElement = null
Return values
bool

getAttribute()

Get element attribute

public getAttribute(string $attribute[, DOMElement $contextNode = null ][, string $path = null ]) : string|null
Parameters
$attribute : string
$contextNode : DOMElement = null
$path : string = null
Return values
string|null

getDomFromString()

Get DOMDocument from content string

public getDomFromString(string $content) : DOMDocument
Parameters
$content : string
Return values
DOMDocument

getDomFromZip()

Get DOMDocument from ZipArchive

public getDomFromZip(string $zipFile, string $xmlFile) : DOMDocument|false
Parameters
$zipFile : string
$xmlFile : string
Tags
throws
Exception
Return values
DOMDocument|false

getElement()

Get element

public getElement(string $path[, DOMElement $contextNode = null ]) : DOMElement|null
Parameters
$path : string
$contextNode : DOMElement = null
Return values
DOMElement|null

getElements()

Get elements

public getElements(string $path[, DOMElement $contextNode = null ]) : DOMNodeList
Parameters
$path : string
$contextNode : DOMElement = null
Return values
DOMNodeList

getValue()

Get element value

public getValue(string $path[, DOMElement $contextNode = null ]) : string|null
Parameters
$path : string
$contextNode : DOMElement = null
Return values
string|null

registerNamespace()

Registers the namespace with the DOMXPath object

public registerNamespace(string $prefix, string $namespaceURI) : bool
Parameters
$prefix : string

The prefix

$namespaceURI : string

The URI of the namespace

Tags
throws
InvalidArgumentException

If called before having loaded the DOM document

Return values
bool

true on success or false on failure

Search results