View Full Version : Xml DOM parsing

06-02-2006, 04:19 PM
Hi All,
I need to check for availability of a specific tag name in Xml DOM parsing using javascript.How do i check for it, is there any method in javascript to handle this.

Waiting for ur replies.

06-02-2006, 05:05 PM
How are you creating your XML DOM ?
any examples of code?

could be as easy as:

var list = DOMDocument.getElementsByTagName("yourtagname");
if (list.length)
// do something...

Katy Vlady
06-08-2006, 10:00 AM
And what about the <div > elements. How to get those with the similar ids?

06-08-2006, 11:46 AM
And what about the <div > elements. How to get those with the similar ids?

XML has nothing to do with HTML or XHTML elements such as <div>
On the other hand, if you are talking about XHTML, the id must be unique on page/session, so that there must not be similar id's.

What, in fact, is your problem? can u detail?

Katy Vlady
06-08-2006, 03:21 PM
I have to parse html page. After that I receive DOM document and I need to get all <div> nodes with the ids that contains some text. :confused: Thank you for help:)

06-08-2006, 03:42 PM
try (untested)

var divs = DOMDocument.getElementsByTagName('div')
for(var i=0;i<divs.length;i++){
if(divs[i].firstChild && divs[i].firstChild.nodeType==3 && divs[i].id!=''){
........do something........

should find all the divs which have text nested as firstChild and have an id

Katy Vlady
06-08-2006, 03:49 PM
I'll try. Thank you:)