Thanks guys, and very useful suggestion.
On Sep 6, 6:32 am, jchimene <[EMAIL PROTECTED]> wrote:
> Part of the answer depends on the intended use of the text. If it's
> simply to be spewed upon the screen as html, you might try the
> following, which is wrapped in DeferredCommand().execute(). The
> xxxContext variables are to maintain context across DeferredCommand co-
> routine calls:
>
> docQuestionnaire = XMLParser.parse(xmlData);
>
> sections =
> docQuestionnaire.getElementsByTagName("section"); //
> possibly "gradingcriterion"?
>
> sectionContext = 0; // increment as
> appropriate
> currentSection = (Element)
> sections.item(sectionContext);
>
> currentItems = currentSection.hasChildNodes() ?
> currentSection.getChildNodes() : null;
> questionContext = 0; // increment as
> appropriate
>
> String s = "";
> Widget iw = null;
> Widget ihp = null;
> for (int i = 0; i <
> currentItems.item(questionContext).getChildNodes().getLength(); i++) {
> if (ELEMENT_NODE ==
> currentItems.item(questionContext).getChildNodes().item(i).getNodeType())
> {
> if (((Element)
> currentItems.item(questionContext).getChildNodes().item(i)).getTagName().to
> LowerCase().matches("info"))
> {
> NodeList nl = ((Element)
> currentItems.item(questionContext)).getChildNodes().item(i).getChildNodes() ;
> iw = new HTML(nl.toString(),
> true);
> String id = ((Element)
> currentItems.item(questionContext).getChildNodes().item(i)).hasAttribute("i
> d")
> ? ((Element)
> currentItems.item(questionContext).getChildNodes().item(i)).getAttribute("i
> d")
> : "html" +
> Integer.toString(Random.nextInt());
>
> iw.getElement().setAttribute("id", id);
> ihp = new HorizontalPanel();
> ihp.add(iw);
> }
> else {
> s += ((Element)
> currentItems.item(questionContext)).getChildNodes().item(i).toString();
> }
> }
> else {
> s += ((Element)
> currentItems.item(questionContext)).getChildNodes().item(i).toString();
> }
> }
>
> -30-
>
> On Sep 4, 10:49 pm, perry <[EMAIL PROTECTED]> wrote:
>
> > thinking about followingxmlfragment:
>
> > <gradingcriterion>
> > <label>Subject/discipline content & knowledge</label>
> > <value>knowledge</value>
> > </gradingcriterion>
>
> > when I use getChildNodes().getLength(), the result I get is 5 instead
> > of 2. I re-edit the abovexmlfragment as a single line:
>
> > <gradingcriterion><label>Subject/discipline content &knowledge</
> > label><value>knowledge</value></gradingcriterion>
>
> > The result I get is 2.
>
> > So it is obvious that "/n" is considered as a child node by GWT. So is
> > there way to walk around this problem?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---