Jump to content

Javascript XML parser question


amorf
 Share

Recommended Posts

Hello Everybody.First of all Im sorry because of my english.I have a working project with a php script, but i'd like to "convert" it to java, so in this way it could be a client side "application".(Maybe the Thread's title wrong so i try to explane it.)I have an xml file (with http:// address) and i want read and display specific parts of it in a html page.XML structure example:<root><books><title><name>Example 1</name><pages>847</pages><writer>Somebody 1</writer><limit>122</limit></title><title><name>Example 2</name><pages>558</pages><writer>Somebody 2</writer><limit>221</limit></title><title><name>Example 3</name><pages>554</pages><writer>Somebody 3</writer><limit>554</limit></title>etc..</books></root>If i want to display example the second book's informations in a html page, like:Name: Example 2Pages: 558Writer:Somebody 2Limit: 221What script should I use?Please be patient im really new in this.Thank You Guys.Amorf.

Link to comment
Share on other sites

You can probably use a regular ajax request to load the XML file. I'm not sure if the Javascript engine for gadgets is different than anything else, I assume it would use the IE engine to render those. So you can look for examples of using IE to send ajax requests via Javascript. There are probably several tutorials online about sending requests for remote content in a gadget also. If the server returns the correct content type for the XML file then the data will be in the responseXML property of the response object, and it will already be a DOM structure. There's a description about how to navigate through an XML document here: http://www.w3schools.com/dom/dom_nodes_navigate.asp

Link to comment
Share on other sites

Yes, i found this article, and i tryed to create a working code, but as i mentioned before i can't use java.I was hoping that maybe someone can atleast grab an example from any article and convert it to my project.If smbody would do that i could extend the script to my claim.Thank you!

Link to comment
Share on other sites

The page I linked you to doesn't have anything to do with Java. W3Schools doesn't even have a Java tutorial at all. Regardless, we're here to teach people how to program, we're not here to do people's work for them. We're happy to help you learn how to do this, but we aren't going to do it for you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...