I would like to query an XML file (see part of the file below), using an input box on a html form, I woud like to type the name of the country eg Albania, and have all the attributes relvant to that country appear on the same form. I have tried using the getElementsByTagName method, but dont know the syntax that will allow me to associate the name of the country with the input box on the form..can someone please help.....
<country id="cid-cia-Albania" continent="Europe" name="Albania" datacode="AL" total_area="28750" population="3249136" population_growth="1.34" infant_mortality="49.2" gdp_agri="55" inflation="16" gdp_total="4100" indep_date="28 11 1912" government="emerging democracy" capital="Tirane">
<ethnicgroups name="Greeks">3</ethnicgroups>
<ethnicgroups name="Albanian">95</ethnicgroups>
<religions name="Muslim">70</religions>
<religions name="Roman Catholic">10</religions>
<religions name="Albanian Orthodox">20</religions>
<borders country="cid-cia-Greece">282</borders>
<borders country="cid-cia-Macedonia">151</borders>
<borders country="cid-cia-Serbia-and-Montenegro">287</borders>
<coasts>Adriatic Sea</coasts>
<coasts>Ionian Sea</coasts>
<coasts>Serbia</coasts>
<coasts>Montenegro</coasts>
</country>
thanks
Jack210

XML DOM and Javascript
ReneeC
//I have to make this interactive, the user will enter the country required, via an input box on a form, XPath will then return the correct values...can you help with the syntax for this... //
You may use a simple string concatenation to get a desired XPath expression. However, be sure to check the input first in order to avoid XPath injection attack: http://www.webappsec.org/projects/threat/classes/xpath_injection.shtml.
Best regards,
Anton
tammali
thank you very much
Jack210
AdeptBlue
Hi,
I have 2 javascript functions as below:
function
cbload(){
var obj2=null; var obj=null; var obj1=document;obj2=obj1.getElementById(
"parId"); for (i=0;i<5;i++){
obj=obj1.createElement(
"div");obj.id=
"div_" + i.toString();obj2.appendChild(obj);
obj=
null;}
obj=
null;obj2=
null;obj1=
null;alert(
'done');}
function
cbunload(){
var obj2=null; var obj=null; var obj1=document;obj2=obj1.getElementById(
"parId");obj=
null; for (i=0;i<5;i++){
obj=obj1.getElementById(
"div_" + i.toString());obj2.removeChild(obj);
obj=
null;}
obj=
null;obj2=
null;obj1=
null;alert(
'done');}
<
input id="Submit1" type="button" value="Load" onclick="cbload()" /> <input id="Button1" type="button" value="UnLoad" onclick="cbunload()" />when i see it using Drip-it tool, After a Load/Unload, I am still seeing DOM Leak as div_0 thru div_4.
Can someone help me in how to completly remove this leak.
Help will be much appreciated
Gurpreet Singh Sawhney
Do you know XPath With IE 6 and later you can use XPath to select/find nodes in an XML DOM document, see the selectNodes/selectSingleNode methods.
Mozilla and Opera 9 also support XPath, although with a completely different API, the W3C DOM Level 3 XPath API.
You would first find the country element with an XPath expression e.g.
//country[@name = 'Albania']
then you could use relative XPath expressions e.g.
coasts
to find all coasts element in that country element selected earlier.