By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,960 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,960 IT Pros & Developers. It's quick & easy.

getElementsByTagNameNS Function Call

P: n/a
When I execute this script with the xml document placed below it . It
fails. Can Anyonw tell me the cause of it.
var root=xmlDoc.documentElement

var temp8 =
xmlDoc.getElementsByTagNameNS('http://www.tryit.com/fiction','title')

temp8 = temp8.item(0);

if(temp8.nodeName == "d:title")
{
return success;
}
else
{
return fialure;

}

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <bookstore>
- <book xmlns:d="http://www.tryit.com/fiction" category="FICTION">
<d:title d:lang="en">The Alchemist</d:title>
<d:author>Paulo Coelho</d:author>
<d:year>2005</d:year>
<d:price>130.00</d:price>
</book>
- <book xmlns:c="http://www.tryit.com/children" category="CHILDREN">
<c:title c:lang="en">Harry Potter</c:title>
<c:author>J K. Rowling</c:author>
<c:year>2005</c:year>
<c:price>429.5</c:price>
</book>
</bookstore>
Thanks in Advance

Regards

Ankush

Oct 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Learner wrote:
When I execute this script with the xml document placed below it . It
fails. Can Anyonw tell me the cause of it.
var root=xmlDoc.documentElement

var temp8 =
xmlDoc.getElementsByTagNameNS('http://www.tryit.com/fiction','title')

temp8 = temp8.item(0);

if(temp8.nodeName == "d:title")
{
return success;
}
else
{
return fialure;

}
Where are the variables |sucess| and |fialure| defined?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 11 '06 #2

P: n/a
Actually

xmlDoc.getElementsByTagNameNS('http://www.tryit.com/fiction','title')

This statement itself returns nodelist that has length as 0 .
I don't know why ??
Martin Honnen wrote:
Learner wrote:
When I execute this script with the xml document placed below it . It
fails. Can Anyonw tell me the cause of it.
var root=xmlDoc.documentElement

var temp8 =
xmlDoc.getElementsByTagNameNS('http://www.tryit.com/fiction','title')

temp8 = temp8.item(0);

if(temp8.nodeName == "d:title")
{
return success;
}
else
{
return fialure;

}

Where are the variables |sucess| and |fialure| defined?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.