I`m trying to get the attribute value of a xml by comparing it to another xml,as follows:
xmlData1 variable has xml like—>
<Root>
<RNA A="100" x="table1" y="car11"/>
<RNA A="101" x="table2" y="car12"/>
<RNA A="102" x="table3" y="car13"/>
<RNA A="103" x="table4" y="car14"/>
<RNA A="104" x="table5" y="car15"/>
<RNA A="105" x="table6" y="car16"/>
<RNA A="106" x="table7" y="car17"/>
<RNA A="107" x="table8" y="car18"/>
<RNA A="108" x="table9" y="car19"/>
</Root>
xmlData2 variable has xml like —>
<Ina>
<RNA B="100" x="table1" y="car11"/>
<RNA B="101" x="table2" y="car12"/>
<RNA B="102" x="table3" y="car13"/>
</Ina>
Here i `ve to compare like
if(xmlData1.getAttribute(x)==xmlData2.getAttribute(x) then
//code goes
How to achive this???please help
It’s reasonable simple. First off, you parse the xml. I’ve put together a X-browser function that fits your needs rather well, actually. You can find it here
Uncomment this line:
Just call it like so:
both
data1anddata2are now arrays, just iterate over them:Just for completeness and clarity, this is the function as used in this example: