Hey.
I haven't been working with XML for that long time, but I am now.
I'm trying to get the value, from the red strings in the following code, but I can't figure out how.
The XML is dynamic and doesn't have a permanent number of items, so I am doing a for();
The XML document.
code:
<myxmldocument>
<items count="2">
<item id="22380">
<name>This is a test</name>
<quality>4</quality>
<icon>test_icon</icon>
</item>
<item id="18952">
<name>Simone's Head</name>
<quality>2</quality>
<icon>icon_for_testing</icon>
</item>
</items>
</myxmldocument>
My code:
code:
var SendItems = "";
var Items = XMLmsg.selectSingleNode("myxmldocument//items");
var ItemLink = XMLmsg.selectSingleNode("myxmldocument//items//item");
if(Items != null)
{
for(var i = 0; i < Items.childNodes.length; i++)
{
Quality = Items.childNodes[i].childNodes[1].text; // Quality
SendItems += "[b]";
switch(Quality) // Name
{
case "0":
SendItems += "[c=#9d9d9d]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "1":
SendItems += "[c=#000000]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "2":
SendItems += "[c=#1eff00]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "3":
SendItems += "[c=#0070dd]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "4":
SendItems += "[c=#a335ee]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "5":
SendItems += "[c=#ff8000]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
case "6":
SendItems += "[c=#e6cc80]" + Items.childNodes[i].childNodes[0].text + "[/c] ";
break;
}
SendItems += "[/b]";
SendItems += "\n";
SendItems += ItemLink.childNodes[0].childNodes[i].text + "\n";
}
I hope, you can help me out of this problem.
Thanks in advance.