473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Using XML DOM output in HTML

25
I am using the xml file as given below

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2.  
  3. <propertyfolio>
  4.   <property_group description="abc">
  5.     <property ref="1" name="One">
  6.             <unit id="2147365895" />
  7.       <units>
  8.         <unit property_ref="1" ref="1" description="description of One" strung_address="Address One" />
  9.         <unit property_ref="1" ref="2" description="description of Two" strung_address="Address Two" />
  10.         <unit property_ref="1" ref="3" description="description of Three" strung_address="Address Three" />
  11.         <unit property_ref="1" ref="4" description="description of Four" strung_address="Address Four" />
  12.       </units>
  13.     </property>
  14.        <property ref="2" name="Two">
  15.             <unit id="37365895" />
  16.       <units>
  17.         <unit property_ref="2" ref="1" description="description of New One" strung_address="New Address One" />
  18.         <unit property_ref="2" ref="2" description="description of New Two" strung_address="New Address Two" />
  19.       </units>
  20.     </property>
  21.     </property_group>
  22.     <property_group description="abc">
  23.            <property ref="2001" name="Two TH One">
  24.             <unit id="1137365895" />
  25.       <units>
  26.         <unit property_ref="2001" ref="1" description="description of Two TH One" strung_address="Address Two TH One" />
  27.         <unit property_ref="2001" ref="2" description="description of Two TH Two" strung_address="Address Two TH Two" />
  28.       </units>
  29.     </property>
  30.     </property_group>
  31. </propertyfolio>
I want to get the information from XML file using DOM so I used the below code

Expand|Select|Wrap|Line Numbers
  1. var xmlDoc;
  2. if (window.ActiveXObject)
  3. {
  4. xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  5. }
  6. else if (document.implementation.createDocument)
  7. {
  8. xmlDoc=document.implementation.createDocument("","",null);
  9. }
  10. else
  11. {
  12. alert('Your browser cannot handle this script');
  13. }
  14. xmlDoc.async=false;
  15. xmlDoc.load("propertyfolio.xml");
  16. x=xmlDoc.getElementsByTagName("property");
  17. i=0;
  18. function next()
  19. {
  20. if (i<x.length)
  21.     {
  22.     i++;
  23.     display();
  24.     }
  25. }
  26.  
  27. function previous()
  28. {
  29. if (i>0)
  30.     {
  31.     i--;
  32.     display();
  33.     }
  34. }
  35. function display()
  36. {
  37. if (i<x.length)
  38.     {
  39.     address=x.item(i).attributes.getNamedItem("strung_address");
  40.                document.getElementById("show").innerHTML="Address: "+ address.value;    
  41. }
  42. else i--;
  43. }
It all works fine, as want to navigate the through property address with next and previous button.

Now I want to work the same navigation with units of a particular property say one we match the property_ref = 2 from XML, all the unit in that property are displayed with the same next and previous button.

Can anyone help me with it.
Mar 19 '08 #1
0 1234

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
12
by: Mark Constant | last post by:
I have a drop-down list now and I got it so when something is selected from the drop down list it calls a JavaScript function. I want it so the value selected from the drop-down list is sent as a...
1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
8
by: Kathleen Dollard | last post by:
Hi, Oleg's answer about attribute value templates led me to look back at a different problem, and wonder if someone else had solved it. I want to output an ASP.NET page. Thus I need to output...
3
by: msnews.microsoft.com | last post by:
Hello All, I am trying to write Web Controls and in most of the samples I came across, I am seeing the following function where a HTML string is written to create HTML Controls. ///...
3
by: bloc | last post by:
I am programming an interactive CV using xml, xslt and java script. The page consists of a header which contains links to various 'sections' on the xml cv, a left and right menu, and a central...
3
by: apiringmvp | last post by:
All, So I am creating a function that gets a short blurb of html from a blog. I would like to retain all html formating and images. The code below works well, with the exception of one issue....
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
25
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.