PDA

View Full Version : XML question, and it's funny because I'm clueless


beau
04-05-2005, 07:39 PM
I am creating an xml file, like this:
<myItem name="Amex: Notify" string="http://amazon.com/" position="otp" label2="screenshot.amexinside.swf">

etc.

Why am I limited to certain keywords? label2 works, but label1 does not. What up with that?

Thanks for your wisdom.

beau
04-06-2005, 09:58 PM
oh come on, I know this is an easy one.

CyanBlue
04-07-2005, 12:39 AM
Maybe there is something you are missing... (See if you have multiple '>'...) I added label1 and it works fine... ;)

data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success)
{
if (success)
{
parseXML(data_xml);
}
};
data_xml.load('xmlTest.xml');

function parseXML(xmlDoc_xml)
{
var doc = xmlDoc_xml.firstChild.childNodes[0];
trace("doc.attributes.name = " + doc.attributes.name);
trace("doc.attributes.string = " + doc.attributes.string);
trace("doc.attributes.position = " + doc.attributes.position);
trace("doc.attributes.label1 = " + doc.attributes.label1);
trace("doc.attributes.label2 = " + doc.attributes.label2);
}

<Item>
<myItem name="Amex: Notify"
string="http://amazon.com/"
position="otp"
label1="some label and what not"
label2="screenshot.amexinside.swf">
</Item>
Output is...
doc.attributes.name = Amex: Notify
doc.attributes.string = http://amazon.com/
doc.attributes.position = otp
doc.attributes.label1 = some label and what not
doc.attributes.label2 = screenshot.amexinside.swf