44 if ( $this->xpath ===
null ) {
45 $this->xpath =
new DOMXPath( $this->node->ownerDocument );
51 if ( $this->node instanceof DOMNodeList ) {
53 foreach ( $this->node as
$node ) {
57 $s = $this->node->ownerDocument->saveXML( $this->node );
66 return $this->node->childNodes ?
new self( $this->node->childNodes ) :
false;
73 return $this->node->firstChild ?
new self( $this->node->firstChild ) :
false;
80 return $this->node->nextSibling ?
new self( $this->node->nextSibling ) :
false;
89 return new self( $this->
getXPath()->query(
$type, $this->node ) );
96 if ( $this->node instanceof DOMNodeList ) {
97 return $this->node->length;
108 $item = $this->node->item( $i );
109 return $item ?
new self( $item ) :
false;
116 if ( $this->node instanceof DOMNodeList ) {
119 return $this->node->nodeName;
134 $names =
$xpath->query(
'name', $this->node );
135 $values =
$xpath->query(
'value', $this->node );
136 if ( !$names->length || !$values->length ) {
137 throw new MWException(
'Invalid brace node passed to ' . __METHOD__ );
139 $name = $names->item( 0 );
140 $index = $name->getAttribute(
'index' );
142 'name' =>
new self( $name ),
144 'value' =>
new self( $values->item( 0 ) ) ];
156 $names =
$xpath->query(
'name', $this->node );
157 $attrs =
$xpath->query(
'attr', $this->node );
158 $inners =
$xpath->query(
'inner', $this->node );
159 $closes =
$xpath->query(
'close', $this->node );
160 if ( !$names->length || !$attrs->length ) {
161 throw new MWException(
'Invalid ext node passed to ' . __METHOD__ );
164 'name' =>
new self( $names->item( 0 ) ),
165 'attr' =>
new self( $attrs->item( 0 ) ) ];
166 if ( $inners->length ) {
167 $parts[
'inner'] =
new self( $inners->item( 0 ) );
169 if ( $closes->length ) {
170 $parts[
'close'] =
new self( $closes->item( 0 ) );
181 if ( $this->
getName() !==
'h' ) {
182 throw new MWException(
'Invalid h node passed to ' . __METHOD__ );
185 'i' => $this->node->getAttribute(
'i' ),
186 'level' => $this->node->getAttribute(
'level' ),
getChildrenOfType( $type)
__construct( $node, $xpath=false)
splitArg()
Split a "<part>" node into an associative array containing:
splitHeading()
Split a "<h>" node.
DOMElement DOMNodeList $node
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
There are three types of nodes: