Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Help with XML >Thread Next - Re: Help with XML RE: Help with XMLTo: NULL Date: 1/31/2005 4:29:00 PM What is your platform/programming language? In "psuedocode", if the current node is <Question> <QuestionTypeID>10</QuestionTypeID> you can conditionally process the Question children by checking the XPath expression if (xmlNode.selectSingleNode("Answer/Question") != null) { // recursively call the children } Regards, Mike Sharp "tedqn@y..." wrote: > I'm having a hard time figuring out how to traverse thru this xml maze. > Basically I want to give the user the abililty to export their quiz > into xml, make changes and upload it back, which I will create a new > quiz structure in the database (I know, it could > have been done completely in xml). The question has some info and > answers. Each answer however, can contain child questions of the same > structure except it has a parent answer ID ... so it would be an > unlimited drill down. > I need to traverse through all the top level question nodes, > pull its info (text, type) and create a question, pull all answers to > that question and create them. If an answer has a sub question, call > the original function recursively (passing the parent answerID to map > it to) and create all the children. I have the code for recursive call > to loop through all child > nodes but just can't seem to retrieve the question's child nodes when > the node name is "Question". Thanks for your help. > > ======================================================================= > <Questionnaire> > <Question> > <QuestionTypeID>1</QuestionTypeID> > <QuestionText>Patient's Name</QuestionText> > <Answer> > <AnswerText></AnswerText> > <AnswerDisplayText></AnswerDisplayText> > </Answer> > </Question> > <Question> > <QuestionTypeID>10</QuestionTypeID> > <QuestionText>Symtoms</QuestionText> > <Answer> > <AnswerText>Has Fever</AnswerText> > <AnswerDisplayText>Fever</AnswerDisplayText> > <Question> > <QuestionTypeID>1</QuestionTypeID> > <QuestionText>Severity (1-10)</QuestionText> > <Answer> > <AnswerText></AnswerText> > <AnswerDisplayText></AnswerDisplayText> > </Answer> > </Question> > </Answer> > <Answer> > <AnswerText>Has Nausea</AnswerText> > <AnswerDisplayText>Nausea</AnswerDisplayText> > </Answer> > <Answer> > <AnswerText>Has Cramp</AnswerText> > <AnswerDisplayText>Cramp</AnswerDisplayText> > </Answer> > </Question> > </Questionnaire> > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
