Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Help with XML

From: rdcpro@---------.------
To: 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>
> 
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent