PHP 5.4.31 Released

DomNode->node_value

(PHP 4 >= 4.1.0)

DomNode->node_value Returns value of a node

Description

string DomNode->node_value ( void )

Returns value of the node. The value has different meanings for the different types of nodes as illustrated in the following table.

Meaning of value
Type Meaning
DomAttribute value of attribute
DomAttribute  
DomCDataSection content
DomComment content of comment
DomDocument null
DomDocumentType null
DomElement null
DomEntity null
DomEntityReference null
DomNotation null
DomProcessingInstruction entire content without target
DomText content of text

add a note add a note

User Contributed Notes 3 notes

up
0
erlend at nymedia dot no
6 years ago
In response to rsl at zonapersonal dot com

Or just make sure you set the right page encoding before you start hot fixing.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Using anything else than Unicode is not really a good strategy anyway.
up
0
rsl at zonapersonal dot com
8 years ago
Inmost work with HTML and browsers you may need to use

$text=utf8_decode($domnode->nodeValue);
or
$text=htmlentities(utf8_decode($domnode->nodeValue));

insted of

$text=$domnode->nodeValue;

To have a browser readable output spetialy if you deal with things like & etc or &amp;&aacute;&aacute; etc.
up
0
Salman
10 years ago
To get the contents of the node, which is for instance:

<a>this is a test</a>

To get the string: "this is a test" use:

// assuming dom is an actual xml-dom
$temp = $dom->get_elements_by_tagname("a");
foreach($temp as $nexta) {
   echo $nexta->get_content();
}

- Salman
http://www.setcomputing.com/
To Top