Re: nextSibling question...

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Julius Mong (jxm96c_at_hotmail.com)
Date: 10/21/04


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
> > ...
> > }
> >
> >
> >
> >
> >
> >
>
>



Relevant Pages

  • Re: Nested Accordion Menu
    ... Let's hope that all this is just invalid HTML and not cluelessly written ... I would recommend not to omit those two tags. ... it may not be obvious where the `head' element ends and the ... may be transformed client-side with XSLT. ...
    (comp.lang.javascript)
  • Re: WebBot Substitution
    ... The Page Title is stored in the page itself, in the <head> section between ... > of the page on the General tab are being published. ... >>tags of a page, not the head section of a page. ... >>FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.extensions.windowsnt)
  • Re: Reading HEAD section META tag (name / content).
    ... all html between two server controls is stuffed into one generic. ... <head runat=server> ... you will a generic for the tag which will have a control collection ... to include the ability to read the inheriting class/page meta tags. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Ruby Version History
    ... construct them from the tags/ directory of the SVN repo. ... to checkout tags you'll get gigabytes of mostly redundant ... svn: Can't write to stream: Broken pipe ...
    (comp.lang.ruby)
  • Javascript between Tags
    ... I'm writing a control that needs to put a clientside javascript between the ... Tags of a webpage where it is placed on. ... to access the HEAD tag. ...
    (microsoft.public.dotnet.framework.aspnet)