Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Data into JavaScript or HTML

Status
Not open for further replies.

hbari

Programmer
Oct 14, 2002
4
CA
hi There!

I am writing to import my XML data into my JavaScript or in simple html file.

Environment:
1. I have an Java applet where I select some computer components. Applet has the following structure
Prudcut Picker
Motherboard Processor
1. Intel 1. Intel P3
2. Asus A 2. Intel P4
3. Asus A2 3. Intel P4
and so on so forth.

When I press “complete button” it give me the entire selected components list in the form of a string:
ASUS A2 Motherboard,ASUS A Motherboard,Intel P3 CPU,Intel P4 1.6 CPU (sperated by comma.

2. I have an XML file called components.xml file is pasted bellow;

3. I want to make an invoice at run time based on selected components using my xml file. Can any body help me out to do that? I will really appreciate if someone gives me solution for my problem… Actually, I have to use several xml files to do the similar work

Here is my simple html file that I tried to do my assignment..but I have gave-up now.

<!—GetArry.html starts here &#61664;
<HTML><HEAD></HEAD><BODY>
<SCRIPT>
var xmlDoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)



function getJavaArrayAsAString() {
var arrayAsAString = &quot;Shahid|Hamid|Sajid|Last|One more|&quot;;
<!-- document.myApplet.getJavaArrayAsAString();*/
realJsString = arrayAsAString + &quot;&quot;;
arrayFromJava = realJsString.split(&quot;|&quot;);
alert(&quot;Java Array length = &quot; + arrayFromJava.length + &quot;\r\n&quot; +
&quot;element 2 is &quot; + arrayFromJava[1]);
-->
<!-- document.write(&quot;Total VAlue are <b>&quot;+arrayFromJava.length+&quot;</b><br/>&quot;); -->
<!-- document.write(&quot;Arra String is <p><b>&quot;+arrayAsAString+&quot;</b><br/>&quot;); -->
document.write(&quot;<from>&quot;)
for (i=0 ; i <= arrayFromJava.length-1 ; i++) {
document.write(&quot;<br><font=arial bgcolor=red><b>&quot;+arrayFromJava+&quot;</b><td width=100 height=6><input type='text' name='hcqty' size=5 maxlength=3 value=0></td></font><br/>&quot;);
/* onchange=&quot;if (isNaN(parseInt(OrderForm.hcqty.value))) {OrderForm.hctotal.value=0; OrderForm.hcqty.value=0}; else OrderForm.hctotal.value=subtotal(eval(OrderForm.hcqty.value),eval(35));&quot;
onblur=&quot;OrderForm.gtotal.value='$'+total(this.form);&quot; value=&quot;0&quot;></b></font>
*/
}
document.write(&quot;</from>&quot;)
}
</SCRIPT>
<FORM>
xmlDoc.async=&quot;false&quot;
xmlDoc.load(&quot;components.xml&quot;)
document.write(xmlDoc.getElementsByTagName(&quot;from&quot;).item(0).text)
document.write(xmlDoc.getElementsByTagName(&quot;from&quot;).item(0).text)
/* <INPUT type=&quot;button&quot; value=&quot;get JAVA array (as a string)&quot;
onClick = &quot;getJavaArrayAsAString();&quot;> */
</FORM>
</BODY></HTML>
<!—GetArray.html ends here &#61664;

Please help me out.

.hbari
Toronto, Canada


<!—Components.xml file starts here &#61664;
<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
<?xml-stylesheet type=&quot;text/css&quot; href=&quot;components.css&quot;?>

<!DOCTYPE ComputerType SYSTEM &quot;components.dtd&quot;>

<ComputerType>
<MotherBoard availability=&quot;yes&quot; RamOnBoard=&quot;128&quot; RamSlot=&quot;1&quot;>
<manufacturer>Sasha Inc.</manufacturer>
<MBType>Asus A</MBType>

<price>$150</price>
<DeliveryDate>4 Days</DeliveryDate>
</MotherBoard>
<MotherBoard availability=&quot;yes&quot; RamOnBoard=&quot;128&quot; RamSlots=&quot;2&quot;>
<manufacturer>Sasha Inc</manufacturer>
<MBType>Intel</MBType>

<price>$175</price>
<DeliveryDate>4 Days</DeliveryDate>
</MotherBoard>
<MotherBoard availability=&quot;yes&quot; RamOnBoard=&quot;128&quot; RamSlots=&quot;2&quot;>
<manufacturer>Sasha Inc</manufacturer>
<MBType>Asus A2</MBType>

<price>$200</price>
<DeliveryDate>4 Days</DeliveryDate>
</MotherBoard>
<CPU availability=&quot;yes&quot;>
<manufacturer>Intel Inc</manufacturer>
<Specification>Intel P3 550Mhz</Specification>

<price>$200</price>
<DeliveryDate>4 Days</DeliveryDate>
</CPU>
<CPU availability=&quot;yes&quot;>
<manufacturer>Intel Inc</manufacturer>
<Specification>Intel P4 1.6Ghz</Specification>

<price>$250</price>
<DeliveryDate>4 Days</DeliveryDate>
</CPU>
<CPU availability=&quot;yes&quot;>
<manufacturer>Intel Inc</manufacturer>
<Specification>Intel P4 2.0Ghz </Specification>

<price>$290</price>
<DeliveryDate>4 Days</DeliveryDate>
</CPU>
</ComputerType>
<!—components.xml files ends here &#61664;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top