Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM textContent Property

XML DOM textContent Property


Attr Object Reference Attr object


Definition and Usage

The textContent property sets or returns the textual content of an attribute.

Syntax

attrObject.textContent


Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and return the textual content of the category attribute:

Example

xmlDoc

=

loadXMLDoc

(

"

books.xml

"

)

;

x

=

xmlDoc

.

getElementsByTagName

(

'

book

'

)

;

for

(

i

=

0

;

i

<

x

.

length

;

i

++

)

{

document

.

write

(

x

.

item

(

i

)

.

attributes

[

0

]

.

textContent

)

;

document

.

write

(

"


"

)

;

}

Output:

COOKING

CHILDREN

WEB

WEB

Try it »


Try it

textContent - Set the text content of an attribute


Attr Object Reference Attr object