Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: xml dom char 1 object required??? [Thread Next] Re: xml dom char 1 object required???To: NULL Date: 4/6/2008 7:14:00 AM On Apr 6, 1:08=A0pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> 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=3DxmlDoc.documentElement.childNodes;
>
> > for (i=3D0;i<m.length;i++)
> > {
>
> > Line 277: m=3DxmlDoc.getElementsByTagName("VDN")[i].attributes;
> > var vdnarxio=3Dm.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.
> =A0 =A0var vdnList =3D xmlDoc.getElementsByTagName("VDN");
> =A0 =A0for (var i =3D 0, l =3D vdnList.length; i < l; i++) {
> =A0 =A0 =A0var vdn =3D vdnList[i];
> =A0 =A0 =A0var id =3D vdn.getAttribute("id");
> =A0 =A0}
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/
Thanks for that :-)
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
