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:[EMAIL PROTECTED] Sent: Monday, April 28, 2008 2:08 PM To: [email protected] 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 <[EMAIL PROTECTED]> wrote: > If you're trying to serialize a document to a string, why not use > DOMWriter::writeToString()? > > > -----Original Message----- > From: Nuno Ferreira [mailto:[EMAIL PROTECTED] > Sent: Monday, April 28, 2008 1:26 PM > To: [email protected] > 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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] > > Sent: Thursday, April 24, 2008 11:40 AM > > To: [email protected] > > 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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] > > > Sent: Wednesday, April 16, 2008 2:40 PM > > > To: [email protected] > > > 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. > > > > > >
