Re: nextSibling question...
From: Julius Mong (jxm96c_at_hotmail.com)
Date: 10/21/04
- Next message: Rahul Chatterjee: "scripting error on dial up connection"
- Previous message: Graham: "How can I get an iFrame to size itself"
- In reply to: Han: "Re: nextSibling question..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 21 Oct 2004 12:10:26 +0100
Hi,
Thanks for your help.
the XML I'm dealing with is not html so it has <head> tags all over the
place, and I need to get for each <head> until the next <head> find all the
tags in between them and process the data contained within these siblings.
So e.g.
<head ... / >
<foo>blablalba</foo>
<body><foo>blablalla</foo><foo>blbaldla</foo></doh>
<head ... / >
and so on...
so what I have done is grab all heads using getElementsbytagname or
something and put them into an array x, and then for every x[i] get its
sibling 1 by 1 while it's not the next head tag, processing each in the
process. And that's why I was doing nextSib = nextSib.nextSibling;
Is there actually a way to use selectNodes from say head, so that I can get
its "body" and its children from there? say
x[i].selectNodes("(//BODY)[1]/*") ? Not sure how the syntax works for
selectNodes...
Thanks,
Jules
"Han" <hp4444@kornet.net.korea> wrote in message
news:uLPY1T0tEHA.2788@TK2MSFTNGP09.phx.gbl...
> Next sibling or child?
>
> Your code assumes an xml structure like,
>
> ... <head/><a/><b/><head/> ...
>
> Right? I suspect your xml is like,
>
> <head><a/><b/>...</head>
>
> Then, what you are searching is not sibling, but child. Anyway,
>
> var x=xmldoc.selectNodes("(//HEAD)[1]/following-sibling::*")
> var x=xmldoc.selectNodes("(//HEAD)[1]/*")
>
> will return node collections according to your needs #1 and #2. The rest
is
> ordinary iteration.
>
> for (var i=0; i < x.length; i++)
>
> "Julius Mong" <jxm96c@hotmail.com> wrote in message
> news:4176a538$0$59460$ed2619ec@ptn-nntp-reader03.plus.net...
> > Hi I've located in my code that the line where I'm reassigning nextSib
to
> > nextSib.nextSibling is causing the error "Object required" in IE6... any
> > ideas why this isn't working? If not this way, how else can I iterate
thru
> > the nodes between <HEAD> nodes in an XML doc?
> >
> > Thanks,
> >
> > Julius
> >
> > ------------------------------------------------------------
> >
> > var x = xmlDoc.getElementsByTagName('HEAD');
> >
> > var nextSib = x[j].nextSibling ;
> >
> > for ( nextSib.nodeName != 'HEAD' )
> > {
> > ...
> > nextSib = nextSib.nextSibling
> > ...
> > }
> >
> >
> >
> >
> >
> >
>
>
- Next message: Rahul Chatterjee: "scripting error on dial up connection"
- Previous message: Graham: "How can I get an iFrame to size itself"
- In reply to: Han: "Re: nextSibling question..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|