Thursday, June 30, 2011

Tree from xml??

Hello my name is Jens and I am a beginner in GWT. I was trying to
teach me this, but right now I'm stuck and need help! I'm trying to
get a menu to work with XML via xmlparse and a for loop. What I think
would be given does not seem to be there and it does not work when I
compiled the file. There is nothing in the html violin is not possible
to preview using GWT Designer. Be grateful for the help! Jens

________________________________________________________________
//Main menu

MenuBar menuBar = new MenuBar(true);
vsp.add(menuBar);

//The xml file for menu

Document doc = XMLParser.parse("Xml/SiteMap.xml");
NodeList elements = doc.getElementsByTagName("bookmark");

//Loop for populate the menu with menuitems
//Doesnt work is it here are in the parser?

for (int i = 0; i < elements.getLength(); i++) {
com.google.gwt.xml.client.Node element = elements.item(i);
NamedNodeMap attrs = element.getAttributes();

//Nodes
String title = attrs.getNamedItem("title").getNodeValue();
String url = attrs.getNamedItem("url").getNodeValue();
System.out.println(title + url + "/n" );

//Menu Populates from xml

MenuItem bookmark =
new MenuItem(title, URL(url));
menuBar.addItem(bookmark);

____________________________________________________________________
CANT FIND WHATS WRONG CAN IT BE INHERITS PROBLEM??

MVH JENS

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment