Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-18-2012, 05:31 AM   PM User | #1
Pervez
New Coder

 
Join Date: Jul 2012
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Pervez is an unknown quantity at this point
Display XML content in HTML page

Hi,

I am newbie , I have application in which check-box tree is present. I want to pre-populate the check-box's if user before checked some of those check box.

For that am getting XML format from my back-end perl script as shown below.like , in below XML only 0, 43,44,45,46 and 50 are coming so only those respective checkbox need to checked on page load.I want to display those checked check-box on page load .How can I do this .......?

I tried with so many examples . but am not getting solution for my problem .Below is my XML format data which is am getting from perl script .

<perldata>
<hashref memory_address="0x86f4880">
<item key="0">1</item>
</hashref>
</perldata>
<perldata>
<hashref memory_address="0x86f4880">
<item key="43">1</item>
</hashref>
</perldata>
<perldata>
<hashref memory_address="0x86f4880">
<item key="44">1</item>
</hashref>
</perldata>
<perldata>
<hashref memory_address="0x86f4880">
<item key="45">1</item>
</hashref>
</perldata>
<perldata>
<hashref memory_address="0x86f4880">
<item key="46">1</item>
</hashref>
</perldata>
<perldata>
<hashref memory_address="0x86f4880">
<item key="50">1</item>
</hashref>
</perldata>



Please Help


Thank You
Pervez
Pervez is offline   Reply With Quote
Old 10-18-2012, 10:04 AM   PM User | #2
lovegameflash
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
lovegameflash is an unknown quantity at this point
You should use XSLT for this job. XSLT is a language that is designed to transform documents from xml to xml. This is very usefull, because xhtml is an xml language. That means that you can convert xml to xhtml using XSLT.

XSLT can be used both serverside and clientside, but beware of the clientside solution. Some browers does not support it, and some only supports older versions wihch might lead to different results.
--------------------------------------
Play the best free online games at Friv
lovegameflash is offline   Reply With Quote
Old 10-18-2012, 06:12 PM   PM User | #3
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
You will have to play with the presentation, but here is barebones xmt to html via js:

Code:
<!DOCTYPE html>
<html>
<body>
<script>
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","test.xml",false);
xmlhttp.send('');
xmlDoc=xmlhttp.responseXML;

document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("perldata");
for (i=0;i<x.length;i++)
  {
  document.write("<tr><td>");
  document.write(x[i].getElementsByTagName("hashref")[0].getAttribute('memory_address'));
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("item")[0].getAttribute('key'));
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("item")[0].childNodes[0].nodeValue);
  document.write("</td></tr>");
  }
document.write("</table>");
</script>

</body>
</html>

Last edited by sunfighter; 10-18-2012 at 08:05 PM..
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, xml

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:36 AM.


Advertisement
Log in to turn off these ads.