I was getting mixed encoded chars in my XML.
Some child nodes were arriving as:
& lt;p& gt;This is our trip to the hotel ... we are one block away& lt;/p& gt; & lt;image src=& quot;Pic_4656.gif& quot; url=& quot;/sites/default/files/images/Pic_4656.gif& quot;/& gt;
Some were not.
Many feed readers can read such mixing just fine by converting before using it. Why the creator of the feed could not use CDATA tags and regular html I don't know.
But I didn't want to display the markup. I wanted to display it as marked up text. I also wanted to parse the nodes and look for some things like image tags.
Anyways I needed to get this app out the door and fast. I didn't wan to fool with making tables and converters. I made this kludge:
_global.convertHTMLSpecialToASCII = function(str) { var tester = _root.createEmptyMovieClip("htmlconverter", this.getNextHighestDepth()); var field = tester.createTextField("field", 0, 0, 0, 0, 0); field.html = true; field.htmlText = str; var out = field.text; removeMovieClip(tester); return out; };
Yes I know, _global. Yuck. I did say it was a kludge.
Then when used whithin parsing a larger XML file:
//we hit a node we know has to have children for our app to work, but it only has one childnode. check for html special chars...
var icantbelievethisstupidity = new XML();
icantbelievethisstupidity.ignoreWhite = true;
icantbelievethisstupidity.parseXML(convertHTMLToASCII(itemsDetails[d].firstChild.toString()));
for(var s=0; s<icantbelievethisstupidity.childNodes.length;s++){
trace(icantbelievethisstupidity.childNodes[s]+",");
}
... continue parsing
Which will result in an XML object you can traverse or convert it to a string instead of looping through and display it as a text file.
This is our trip to the hotel ... we are one block away, ,
If anyone knows how to get rid of special html chars at data load time when the file is of mixed representation, let me know.
aaaaaargh.
feeling your pain bro.....
I had to ensure were only used feeds that actually followed RSS standards. The HTML should NEVER be in there in the first place. A proper XSL attachment to Line 2 would more than allow them to do whatever visualization they wanted to do with the data.
Fuck programmers.
sorry no ideas escape and un dont seem to help, but you have something that is working then..
I would of thought that the _global and repeated lines could be avoided, if you using a recursive as2 xml to object/array parser like the one I use then I would have thought you could call the convertHTMLToASCII() on text node from the class, in the same way I convert values to boolean, string, or number, I have posted the class recently.