XPower

package

Default

Methods

Creates a document element from a raw XML data.

__(String $data) : \DOMDocumentFragment
uses

method must be inherited to work properly.

Arguments

$data

String



Raw XML data

Response

\DOMDocumentFragment



Returns a DOMDocumentFragment which content is the newly created element.

__construct

__construct( $xml_dir = NULL) 

Arguments

$xml_dir

__select

__select( $selectors) 

Arguments

$selectors

Closes and saves the changes to the current XML file.

close() : Boolean
final

Response

Boolean



Returns TRUE on success, or FALSE on error or failure.

Connects to a XML document and loads it. The file extension is optional.

connect(String $file_name) : Boolean
final

Arguments

$file_name

String



Response

Boolean



Returns TRUE on success, or FALSE on error or failure.

Selects an element or a set of elements with a specific class attribute.

getElementByClass(String $class) : \XPowerNodeList
final

Arguments

$class

String



Value of the class attribute

Response

\XPowerNodeList



Returns a XPowerNodeList object.

Selects an element with a specific unique id identifier.

getElementById(String $id) : \DOMNode
final

Arguments

$id

String



Value of the id identifier

Response

\DOMNode



Returns a DOMNode object

Select an element or a set of elements with a specific attribute identifier.

getElementsByAttrName(String $attr) : \XPowerNodeList
final

Arguments

$attr

String



Value of the attribue

Response

\XPowerNodeList



Returns a XPowerNodeList object

Selects an element or a set of elements with a specific tag.

getElementsByTagName(String $tag) : \XPowerNodeList
final

Arguments

$tag

String



Tag name

Response

\XPowerNodeList



Returns a XPowerNodeList object

getSelectorNode

getSelectorNode( $selector) 

Arguments

$selector

Selects an element or a set of elements using a CSS selector. Major CSS selector are supported; a little bit difference in pseudo-selector is the presence of a double dot (:) after the type selector (example: books > book:[price>=20.00$]).

select(String $selector = null, \DOMElement $context = null,  $flags = XPower_SELECT_RESET) : \XPowerNodeList
final

Arguments

$selector

String

[Optional]

CSS selector for selection. Multiple selectors may be used at once by separating them with a comma (,). When omitted, all the document elements are selected as a whole.

$context

\DOMElement

[Optional]

A DOM element to refer to when selecting; it's the selection context (the element from which the selection begin).

$flags

Response

\XPowerNodeList



Returns a XPowerNodeList object

Properties

Holds XML document's directory name

xml_dir : String
var

Type(s)

String

Holds XML document element

parser : \DOMElement
var

Type(s)

\DOMElement

Holds the document root element

root : \DOMElement
var

Type(s)

\DOMElement

Current selected elements' list

xml_query : Array
var

Type(s)

Array

The current XML file name

file_name : String
var

Type(s)

String