What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Get value from XML

Get value from XML
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Get value from XML
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.

This post was edited on 04-19-2008 at 07:57 PM by SnuZZer.
04-19-2008 07:55 PM
Profile E-Mail PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Get value from XML
With a lot of searching and using of my little knowledge, I've figured out of to do this.

I've deleted ItemLink and now using Items.

Then I've replaced the following line:

SendItems += ItemLink.childNodes[0].childNodes[i].text + "\n";
to
SendItems += ItemLink.childNodes[i].getAttribute("id") + "\n";

So now my code looks like this:
code:
var SendItems = "";
   
    var Items = XMLmsg.selectSingleNode("myxmldocument//items");
   
    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 += SendItems += Items.childNodes[i].getAttribute("id") + "\n";
        }
04-19-2008 08:46 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On