|
-
Return individual word in an XML node
I have a pretty simple question, how do I reference an individual word in an XML node. For example
Code:
<tag>word1 , word2 , word 3 , word 4, word5</tag>
where I want to refer to all these tags individually instead of as a whole string.
(I'm guessing I would use split() method to return an Array)
If I can make the example return an Array of tags. How do I feed each each tag into it's own XML node? Like below,
Code:
<tag>word1</tag>
<tag>word2</tag>
<tag>word3</tag>
<tag>word4</tag>
<tag>word5</tag>
-
Once you have the XML node you are interested in, use toString() to get the content as a String. Then use split(",") to get an array of the parts (including spaces). You could then trim spaces out if you want. Then iterate through your new array and create new XML for each entry and use appendChild on some other XML to put your new tags in as child nodes.
-
Thanks that was very helpful! Works perfectly now
Code:
for each(var bXML:XML in aXML)
{
var str:String = aXML;
var re:RegExp = /(,)/
var results:Array = str.split(re);
for each(var cXML:String in results)
{
var indXML = new XML("<a>" + cXML + "</a>");
if(indXML != ","){
myXML.appendChild(indXML);
}
indXML.@href = "http://www.ucubd.com";
indXML.@style = "font-size: 8pt;";
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|