Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - xml dom char 1 object required??? >Thread Next - Re: xml dom char 1 object required??? Re: xml dom char 1 object required???To: NULL Date: 4/6/2008 2:09:00 PM
Ivan wrote:
> Hi i am usign teh following loop to go find a note vdn and get its
> attribut value but i am getting "char 1 object required" what's wrong
> with that piece of code???
>
> Thanks
>
> var m=xmlDoc.documentElement.childNodes;
>
> for (i=0;i<m.length;i++)
> {
>
> Line 277: m=xmlDoc.getElementsByTagName("VDN")[i].attributes;
> var vdnarxio=m.getNamedItem("id").nodeValue;
> }
Well you use m.length where m is the childNodes collection of the
documentElement, but instead of looping through that collection you loop
through getElementsByTagName("VDN") which is a different collection.
Additionally you use the same variable m to assign a different
collection, the attributes collection, that can't work.
So instead of your code you should rather use e.g.
var vdnList = xmlDoc.getElementsByTagName("VDN");
for (var i = 0, l = vdnList.length; i < l; i++) {
var vdn = vdnList[i];
var id = vdn.getAttribute("id");
}
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
