XML reading is working. How do I use a text attribute operation in code?

niccosw

  • Posts: 91
I was able to get XML reading working. I used this Kirupa tutorial:
http://www.kirupa.com/net/reading_xml_directly_pg1.htm

I'd like to use an attribute for the bookInput operation so users don't have to dig into the code, they can just set the fields to return. However, every time I pass it, it reads it as a string. Using {} and [] doesn't work. Any other ideas?

Jon

  • *
  • Posts: 17529
Put an @ before the attribute's name (where attribute means the XML attribute).

For example

var n:Number = xml.@someValue;

niccosw

  • Posts: 91
Actually, I meant a behavior attribute not an XML attribute. I should have been more specific.

I solved the problem by using child() methods with behavior attributes specifying the element names.

So this:
print(bookInput.Book.author.text[0]));

can be replaced by this:
print(bookInput.Book.child(_XMLElement).text[0]);

I'll try to release a new XML behavior soon that uses attributes. However, I doubt many people will be interest in using it until the security sandbox issue is dealt with since it breaks when loaded to web portals. At least, I think it's the SS that is breaking it.