You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Nuno Ferreira <nu...@gmail.com> on 2008/04/16 20:39:32 UTC

How to know a node position in the tree

I tried a couple of tricks to see if a node is positioned one level behind
in the tree but none of them worked.

How to check if the current node is one level behind in the tree compared to
the previous one?


Thank you.

Re: How to know a node position in the tree

Posted by Nuno Ferreira <nu...@gmail.com>.
Yes and probably is going to be the best decision since hard-code isn't
getting me anywhere.


Thanks

On Mon, Apr 28, 2008 at 10:33 PM, David Bertoni <db...@apache.org> wrote:

> Nuno Ferreira wrote:
>
>> The problem is that i want to put in a string a slightly different XML,
>> therefore the method writeToString doesn't work for me. Basically my
>> application has an XML for users and an deviated XML version for the
>> machine
>> to work with. So basically my application has to manually translate the
>> XML
>> for users.
>>
> Have you considered using an XSLT stylesheet to accomplish this?  It would
> certainly be more flexible than a hard-coded SAX solution.
>
> Dave
>

Re: How to know a node position in the tree

Posted by David Bertoni <db...@apache.org>.
Nuno Ferreira wrote:
> The problem is that i want to put in a string a slightly different XML,
> therefore the method writeToString doesn't work for me. Basically my
> application has an XML for users and an deviated XML version for the machine
> to work with. So basically my application has to manually translate the XML
> for users.
Have you considered using an XSLT stylesheet to accomplish this?  It 
would certainly be more flexible than a hard-coded SAX solution.

Dave

Re: How to know a node position in the tree

Posted by Nuno Ferreira <nu...@gmail.com>.
On Mon, Apr 28, 2008 at 7:57 PM, Jesse Pelton <js...@pkc.com> wrote:

> OK, I won't ask about the two versions, though "don't ask" usually means
> "this really should be fixed."


It's a software requirement... nothing that can be done :-)


>
>
> Are you sure that the two versions so different that you can't get the
> desired output with DOMWriter feature flags and a DOMWriterFilter?  Or
> is that what you're trying to do?  (Remember, I don't know anything
> about your implementation, because I haven't seen any code...)


Possibly i could use those options, but knowing the position of a node would
make things much more easier even for other simple tasks.



Thanks.


>
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Monday, April 28, 2008 2:08 PM
> To: c-users@xerces.apache.org
> Subject: Re: How to know a node position in the tree
>
> The problem is that i want to put in a string a slightly different XML,
> therefore the method writeToString doesn't work for me. Basically my
> application has an XML for users and an deviated XML version for the
> machine
> to work with. So basically my application has to manually translate the
> XML
> for users.
>
>
> P.S. don't ask about the two versions. ;-)
>
> Thanks.
>
> On Mon, Apr 28, 2008 at 6:49 PM, Jesse Pelton <js...@pkc.com> wrote:
>
> > If you're trying to serialize a document to a string, why not use
> > DOMWriter::writeToString()?
> >
> >
> > -----Original Message-----
> > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > Sent: Monday, April 28, 2008 1:26 PM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to know a node position in the tree
> >
> > Imagining that some info might be not present, like in the following
> > example, Michael has no age
> >
> > Example:
> >
> > <population>
> >  <person>
> >     <name>John</name>
> >     <age>54</age>
> >  </person>
> >  <person>
> >      <name>Michael</name>
> >  </person>
> > </population>
> >
> > I want to write the previous XML to a continuous string:
> >
> > char* xml =
> >
> "<population><person><name>John</name><age>54</age></person><person><nam
> > e>Michael</name></person></population>"
> >
> > since i'm reading the XML file from the top i get:
> >
> > field name: population ; field value:
> > field name: person ; field value:
> > field name: name ; field value: John
> > field name: age ; field value: 54
> > field name: person ; field value:
> > field name: name ; field value: Michael
> >
> > What i need to know is that after the age from John, i need to close
> the
> > tag
> > person </person> and open a new one <person>... Since the age might be
> > not
> > present, the closing tag </person> might come after the </name> tag.
> > This is why i'm asking if there is a way to know if the tag i'm
> reading
> > now
> > is in a different depth in the tree compared to the previous tag.
> >
> > If this is not possible, you are welcome to suggest other approaches
> :-)
> >
> > Thank you
> >
> >
> >
> >
> >
> > On Thu, Apr 24, 2008 at 5:16 PM, Jesse Pelton <js...@pkc.com> wrote:
> >
> > > I'm going to make a wild guess that you're looking for, say, <name>
> > > elements in the document, then processing them. Then you do the same
> > > thing for <age> elements, and you need to make sure that "John" ends
> > up
> > > with an age of "54" and not some other age.
> > >
> > > If that's the case, I think you need to invert your processing
> model.
> > > Instead of searching for <name> and <age> elements, look for
> <person>
> > > elements and process the children of each one.  All the children of
> a
> > > given <person> element will relate to the same person if your
> > documents
> > > are rational.
> > >
> > > If I'm off base, maybe you should send a short code sample that
> > > demonstrates what you're trying to do.
> > >
> > > -----Original Message-----
> > > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > > Sent: Thursday, April 24, 2008 11:40 AM
> > > To: c-users@xerces.apache.org
> > > Subject: Re: How to know a node position in the tree
> > >
> > > Hi,
> > >
> > > i'm using DOM and XPath from Xerces 3.0.0b
> > > Basically in the following example, I want to know that after the
> > <age>
> > > tag,
> > > this person info is over and another one might come next. So i have
> to
> > > know
> > > that the second <person> tag comes first in the tree compared to
> > <name>
> > > or
> > > <age>.
> > >
> > > Hope i made myself clear this time.
> > > Thanks.
> > >
> > > <population>
> > >  <person>
> > >     <name>John</name>
> > >     <age>54</age>
> > >  </person>
> > >  <person>
> > >      (...)
> > >  </person>
> > > </population>
> > >
> > > On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:
> > >
> > > > I think you'll need to say a little more.  Are you using DOM or
> SAX?
> > > > What do you mean by "one level behind?"  Do you want to know if
> one
> > > node
> > > > is the parent of another?
> > > >
> > > > -----Original Message-----
> > > > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > > > Sent: Wednesday, April 16, 2008 2:40 PM
> > > > To: c-users@xerces.apache.org
> > > > Subject: How to know a node position in the tree
> > > >
> > > > I tried a couple of tricks to see if a node is positioned one
> level
> > > > behind
> > > > in the tree but none of them worked.
> > > >
> > > > How to check if the current node is one level behind in the tree
> > > > compared to
> > > > the previous one?
> > > >
> > > >
> > > > Thank you.
> > > >
> > >
> >
>

RE: How to know a node position in the tree

Posted by Jesse Pelton <js...@PKC.com>.
OK, I won't ask about the two versions, though "don't ask" usually means
"this really should be fixed."

Are you sure that the two versions so different that you can't get the
desired output with DOMWriter feature flags and a DOMWriterFilter?  Or
is that what you're trying to do?  (Remember, I don't know anything
about your implementation, because I haven't seen any code...)

-----Original Message-----
From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com] 
Sent: Monday, April 28, 2008 2:08 PM
To: c-users@xerces.apache.org
Subject: Re: How to know a node position in the tree

The problem is that i want to put in a string a slightly different XML,
therefore the method writeToString doesn't work for me. Basically my
application has an XML for users and an deviated XML version for the
machine
to work with. So basically my application has to manually translate the
XML
for users.


P.S. don't ask about the two versions. ;-)

Thanks.

On Mon, Apr 28, 2008 at 6:49 PM, Jesse Pelton <js...@pkc.com> wrote:

> If you're trying to serialize a document to a string, why not use
> DOMWriter::writeToString()?
>
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Monday, April 28, 2008 1:26 PM
> To: c-users@xerces.apache.org
> Subject: Re: How to know a node position in the tree
>
> Imagining that some info might be not present, like in the following
> example, Michael has no age
>
> Example:
>
> <population>
>  <person>
>     <name>John</name>
>     <age>54</age>
>  </person>
>  <person>
>      <name>Michael</name>
>  </person>
> </population>
>
> I want to write the previous XML to a continuous string:
>
> char* xml =
>
"<population><person><name>John</name><age>54</age></person><person><nam
> e>Michael</name></person></population>"
>
> since i'm reading the XML file from the top i get:
>
> field name: population ; field value:
> field name: person ; field value:
> field name: name ; field value: John
> field name: age ; field value: 54
> field name: person ; field value:
> field name: name ; field value: Michael
>
> What i need to know is that after the age from John, i need to close
the
> tag
> person </person> and open a new one <person>... Since the age might be
> not
> present, the closing tag </person> might come after the </name> tag.
> This is why i'm asking if there is a way to know if the tag i'm
reading
> now
> is in a different depth in the tree compared to the previous tag.
>
> If this is not possible, you are welcome to suggest other approaches
:-)
>
> Thank you
>
>
>
>
>
> On Thu, Apr 24, 2008 at 5:16 PM, Jesse Pelton <js...@pkc.com> wrote:
>
> > I'm going to make a wild guess that you're looking for, say, <name>
> > elements in the document, then processing them. Then you do the same
> > thing for <age> elements, and you need to make sure that "John" ends
> up
> > with an age of "54" and not some other age.
> >
> > If that's the case, I think you need to invert your processing
model.
> > Instead of searching for <name> and <age> elements, look for
<person>
> > elements and process the children of each one.  All the children of
a
> > given <person> element will relate to the same person if your
> documents
> > are rational.
> >
> > If I'm off base, maybe you should send a short code sample that
> > demonstrates what you're trying to do.
> >
> > -----Original Message-----
> > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > Sent: Thursday, April 24, 2008 11:40 AM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to know a node position in the tree
> >
> > Hi,
> >
> > i'm using DOM and XPath from Xerces 3.0.0b
> > Basically in the following example, I want to know that after the
> <age>
> > tag,
> > this person info is over and another one might come next. So i have
to
> > know
> > that the second <person> tag comes first in the tree compared to
> <name>
> > or
> > <age>.
> >
> > Hope i made myself clear this time.
> > Thanks.
> >
> > <population>
> >  <person>
> >     <name>John</name>
> >     <age>54</age>
> >  </person>
> >  <person>
> >      (...)
> >  </person>
> > </population>
> >
> > On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:
> >
> > > I think you'll need to say a little more.  Are you using DOM or
SAX?
> > > What do you mean by "one level behind?"  Do you want to know if
one
> > node
> > > is the parent of another?
> > >
> > > -----Original Message-----
> > > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > > Sent: Wednesday, April 16, 2008 2:40 PM
> > > To: c-users@xerces.apache.org
> > > Subject: How to know a node position in the tree
> > >
> > > I tried a couple of tricks to see if a node is positioned one
level
> > > behind
> > > in the tree but none of them worked.
> > >
> > > How to check if the current node is one level behind in the tree
> > > compared to
> > > the previous one?
> > >
> > >
> > > Thank you.
> > >
> >
>

Re: How to know a node position in the tree

Posted by Nuno Ferreira <nu...@gmail.com>.
The problem is that i want to put in a string a slightly different XML,
therefore the method writeToString doesn't work for me. Basically my
application has an XML for users and an deviated XML version for the machine
to work with. So basically my application has to manually translate the XML
for users.


P.S. don't ask about the two versions. ;-)

Thanks.

On Mon, Apr 28, 2008 at 6:49 PM, Jesse Pelton <js...@pkc.com> wrote:

> If you're trying to serialize a document to a string, why not use
> DOMWriter::writeToString()?
>
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Monday, April 28, 2008 1:26 PM
> To: c-users@xerces.apache.org
> Subject: Re: How to know a node position in the tree
>
> Imagining that some info might be not present, like in the following
> example, Michael has no age
>
> Example:
>
> <population>
>  <person>
>     <name>John</name>
>     <age>54</age>
>  </person>
>  <person>
>      <name>Michael</name>
>  </person>
> </population>
>
> I want to write the previous XML to a continuous string:
>
> char* xml =
> "<population><person><name>John</name><age>54</age></person><person><nam
> e>Michael</name></person></population>"
>
> since i'm reading the XML file from the top i get:
>
> field name: population ; field value:
> field name: person ; field value:
> field name: name ; field value: John
> field name: age ; field value: 54
> field name: person ; field value:
> field name: name ; field value: Michael
>
> What i need to know is that after the age from John, i need to close the
> tag
> person </person> and open a new one <person>... Since the age might be
> not
> present, the closing tag </person> might come after the </name> tag.
> This is why i'm asking if there is a way to know if the tag i'm reading
> now
> is in a different depth in the tree compared to the previous tag.
>
> If this is not possible, you are welcome to suggest other approaches :-)
>
> Thank you
>
>
>
>
>
> On Thu, Apr 24, 2008 at 5:16 PM, Jesse Pelton <js...@pkc.com> wrote:
>
> > I'm going to make a wild guess that you're looking for, say, <name>
> > elements in the document, then processing them. Then you do the same
> > thing for <age> elements, and you need to make sure that "John" ends
> up
> > with an age of "54" and not some other age.
> >
> > If that's the case, I think you need to invert your processing model.
> > Instead of searching for <name> and <age> elements, look for <person>
> > elements and process the children of each one.  All the children of a
> > given <person> element will relate to the same person if your
> documents
> > are rational.
> >
> > If I'm off base, maybe you should send a short code sample that
> > demonstrates what you're trying to do.
> >
> > -----Original Message-----
> > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > Sent: Thursday, April 24, 2008 11:40 AM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to know a node position in the tree
> >
> > Hi,
> >
> > i'm using DOM and XPath from Xerces 3.0.0b
> > Basically in the following example, I want to know that after the
> <age>
> > tag,
> > this person info is over and another one might come next. So i have to
> > know
> > that the second <person> tag comes first in the tree compared to
> <name>
> > or
> > <age>.
> >
> > Hope i made myself clear this time.
> > Thanks.
> >
> > <population>
> >  <person>
> >     <name>John</name>
> >     <age>54</age>
> >  </person>
> >  <person>
> >      (...)
> >  </person>
> > </population>
> >
> > On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:
> >
> > > I think you'll need to say a little more.  Are you using DOM or SAX?
> > > What do you mean by "one level behind?"  Do you want to know if one
> > node
> > > is the parent of another?
> > >
> > > -----Original Message-----
> > > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > > Sent: Wednesday, April 16, 2008 2:40 PM
> > > To: c-users@xerces.apache.org
> > > Subject: How to know a node position in the tree
> > >
> > > I tried a couple of tricks to see if a node is positioned one level
> > > behind
> > > in the tree but none of them worked.
> > >
> > > How to check if the current node is one level behind in the tree
> > > compared to
> > > the previous one?
> > >
> > >
> > > Thank you.
> > >
> >
>

RE: How to know a node position in the tree

Posted by Jesse Pelton <js...@PKC.com>.
If you're trying to serialize a document to a string, why not use
DOMWriter::writeToString()?


-----Original Message-----
From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com] 
Sent: Monday, April 28, 2008 1:26 PM
To: c-users@xerces.apache.org
Subject: Re: How to know a node position in the tree

Imagining that some info might be not present, like in the following
example, Michael has no age

Example:

<population>
  <person>
     <name>John</name>
     <age>54</age>
  </person>
  <person>
      <name>Michael</name>
  </person>
</population>

I want to write the previous XML to a continuous string:

char* xml =
"<population><person><name>John</name><age>54</age></person><person><nam
e>Michael</name></person></population>"

since i'm reading the XML file from the top i get:

field name: population ; field value:
field name: person ; field value:
field name: name ; field value: John
field name: age ; field value: 54
field name: person ; field value:
field name: name ; field value: Michael

What i need to know is that after the age from John, i need to close the
tag
person </person> and open a new one <person>... Since the age might be
not
present, the closing tag </person> might come after the </name> tag.
This is why i'm asking if there is a way to know if the tag i'm reading
now
is in a different depth in the tree compared to the previous tag.

If this is not possible, you are welcome to suggest other approaches :-)

Thank you





On Thu, Apr 24, 2008 at 5:16 PM, Jesse Pelton <js...@pkc.com> wrote:

> I'm going to make a wild guess that you're looking for, say, <name>
> elements in the document, then processing them. Then you do the same
> thing for <age> elements, and you need to make sure that "John" ends
up
> with an age of "54" and not some other age.
>
> If that's the case, I think you need to invert your processing model.
> Instead of searching for <name> and <age> elements, look for <person>
> elements and process the children of each one.  All the children of a
> given <person> element will relate to the same person if your
documents
> are rational.
>
> If I'm off base, maybe you should send a short code sample that
> demonstrates what you're trying to do.
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Thursday, April 24, 2008 11:40 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to know a node position in the tree
>
> Hi,
>
> i'm using DOM and XPath from Xerces 3.0.0b
> Basically in the following example, I want to know that after the
<age>
> tag,
> this person info is over and another one might come next. So i have to
> know
> that the second <person> tag comes first in the tree compared to
<name>
> or
> <age>.
>
> Hope i made myself clear this time.
> Thanks.
>
> <population>
>  <person>
>     <name>John</name>
>     <age>54</age>
>  </person>
>  <person>
>      (...)
>  </person>
> </population>
>
> On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:
>
> > I think you'll need to say a little more.  Are you using DOM or SAX?
> > What do you mean by "one level behind?"  Do you want to know if one
> node
> > is the parent of another?
> >
> > -----Original Message-----
> > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > Sent: Wednesday, April 16, 2008 2:40 PM
> > To: c-users@xerces.apache.org
> > Subject: How to know a node position in the tree
> >
> > I tried a couple of tricks to see if a node is positioned one level
> > behind
> > in the tree but none of them worked.
> >
> > How to check if the current node is one level behind in the tree
> > compared to
> > the previous one?
> >
> >
> > Thank you.
> >
>

Re: How to know a node position in the tree

Posted by Nuno Ferreira <nu...@gmail.com>.
Imagining that some info might be not present, like in the following
example, Michael has no age

Example:

<population>
  <person>
     <name>John</name>
     <age>54</age>
  </person>
  <person>
      <name>Michael</name>
  </person>
</population>

I want to write the previous XML to a continuous string:

char* xml =
"<population><person><name>John</name><age>54</age></person><person><name>Michael</name></person></population>"

since i'm reading the XML file from the top i get:

field name: population ; field value:
field name: person ; field value:
field name: name ; field value: John
field name: age ; field value: 54
field name: person ; field value:
field name: name ; field value: Michael

What i need to know is that after the age from John, i need to close the tag
person </person> and open a new one <person>... Since the age might be not
present, the closing tag </person> might come after the </name> tag.
This is why i'm asking if there is a way to know if the tag i'm reading now
is in a different depth in the tree compared to the previous tag.

If this is not possible, you are welcome to suggest other approaches :-)

Thank you





On Thu, Apr 24, 2008 at 5:16 PM, Jesse Pelton <js...@pkc.com> wrote:

> I'm going to make a wild guess that you're looking for, say, <name>
> elements in the document, then processing them. Then you do the same
> thing for <age> elements, and you need to make sure that "John" ends up
> with an age of "54" and not some other age.
>
> If that's the case, I think you need to invert your processing model.
> Instead of searching for <name> and <age> elements, look for <person>
> elements and process the children of each one.  All the children of a
> given <person> element will relate to the same person if your documents
> are rational.
>
> If I'm off base, maybe you should send a short code sample that
> demonstrates what you're trying to do.
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Thursday, April 24, 2008 11:40 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to know a node position in the tree
>
> Hi,
>
> i'm using DOM and XPath from Xerces 3.0.0b
> Basically in the following example, I want to know that after the <age>
> tag,
> this person info is over and another one might come next. So i have to
> know
> that the second <person> tag comes first in the tree compared to <name>
> or
> <age>.
>
> Hope i made myself clear this time.
> Thanks.
>
> <population>
>  <person>
>     <name>John</name>
>     <age>54</age>
>  </person>
>  <person>
>      (...)
>  </person>
> </population>
>
> On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:
>
> > I think you'll need to say a little more.  Are you using DOM or SAX?
> > What do you mean by "one level behind?"  Do you want to know if one
> node
> > is the parent of another?
> >
> > -----Original Message-----
> > From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> > Sent: Wednesday, April 16, 2008 2:40 PM
> > To: c-users@xerces.apache.org
> > Subject: How to know a node position in the tree
> >
> > I tried a couple of tricks to see if a node is positioned one level
> > behind
> > in the tree but none of them worked.
> >
> > How to check if the current node is one level behind in the tree
> > compared to
> > the previous one?
> >
> >
> > Thank you.
> >
>

RE: How to know a node position in the tree

Posted by Jesse Pelton <js...@PKC.com>.
I'm going to make a wild guess that you're looking for, say, <name>
elements in the document, then processing them. Then you do the same
thing for <age> elements, and you need to make sure that "John" ends up
with an age of "54" and not some other age.

If that's the case, I think you need to invert your processing model.
Instead of searching for <name> and <age> elements, look for <person>
elements and process the children of each one.  All the children of a
given <person> element will relate to the same person if your documents
are rational.

If I'm off base, maybe you should send a short code sample that
demonstrates what you're trying to do.

-----Original Message-----
From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com] 
Sent: Thursday, April 24, 2008 11:40 AM
To: c-users@xerces.apache.org
Subject: Re: How to know a node position in the tree

Hi,

i'm using DOM and XPath from Xerces 3.0.0b
Basically in the following example, I want to know that after the <age>
tag,
this person info is over and another one might come next. So i have to
know
that the second <person> tag comes first in the tree compared to <name>
or
<age>.

Hope i made myself clear this time.
Thanks.

<population>
  <person>
     <name>John</name>
     <age>54</age>
  </person>
  <person>
      (...)
  </person>
</population>

On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:

> I think you'll need to say a little more.  Are you using DOM or SAX?
> What do you mean by "one level behind?"  Do you want to know if one
node
> is the parent of another?
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Wednesday, April 16, 2008 2:40 PM
> To: c-users@xerces.apache.org
> Subject: How to know a node position in the tree
>
> I tried a couple of tricks to see if a node is positioned one level
> behind
> in the tree but none of them worked.
>
> How to check if the current node is one level behind in the tree
> compared to
> the previous one?
>
>
> Thank you.
>

Re: How to know a node position in the tree

Posted by Nuno Ferreira <nu...@gmail.com>.
Hi,

i'm using DOM and XPath from Xerces 3.0.0b
Basically in the following example, I want to know that after the <age> tag,
this person info is over and another one might come next. So i have to know
that the second <person> tag comes first in the tree compared to <name> or
<age>.

Hope i made myself clear this time.
Thanks.

<population>
  <person>
     <name>John</name>
     <age>54</age>
  </person>
  <person>
      (...)
  </person>
</population>

On Fri, Apr 18, 2008 at 12:39 PM, Jesse Pelton <js...@pkc.com> wrote:

> I think you'll need to say a little more.  Are you using DOM or SAX?
> What do you mean by "one level behind?"  Do you want to know if one node
> is the parent of another?
>
> -----Original Message-----
> From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com]
> Sent: Wednesday, April 16, 2008 2:40 PM
> To: c-users@xerces.apache.org
> Subject: How to know a node position in the tree
>
> I tried a couple of tricks to see if a node is positioned one level
> behind
> in the tree but none of them worked.
>
> How to check if the current node is one level behind in the tree
> compared to
> the previous one?
>
>
> Thank you.
>

RE: How to know a node position in the tree

Posted by Jesse Pelton <js...@PKC.com>.
I think you'll need to say a little more.  Are you using DOM or SAX?
What do you mean by "one level behind?"  Do you want to know if one node
is the parent of another?

-----Original Message-----
From: Nuno Ferreira [mailto:nuno.and.ferreira@gmail.com] 
Sent: Wednesday, April 16, 2008 2:40 PM
To: c-users@xerces.apache.org
Subject: How to know a node position in the tree

I tried a couple of tricks to see if a node is positioned one level
behind
in the tree but none of them worked.

How to check if the current node is one level behind in the tree
compared to
the previous one?


Thank you.