Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get text for element in javascript

Status
Not open for further replies.

gacaccia

Technical User
May 15, 2002
258
US
hi all,

i'm making an IE application using xml for the data source and javascript to interact with the xml and display it. i'm using the following type of code to extract nodes from the document...

Code:
var xmlNodes = xmlTag.XMLDocument.selectNodes("e1/e2");

once i have this, i'm familiar with two methods for retrieving data from the individual nodes. for returning attributes of an element i use...

Code:
xmlNodes[i].getAttribute("attribute");

for retrieving the text in an element, i use...

Code:
xmlNodes[i].text;

the problem is, the latter one is only usable to me if there are no child elements, as it returns the text for all child elements also if any are present, and i only want to get the text for the given element. does anyone know of a method i can use for getting only the text of an element, even if it has child elements?

thanks,

glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top