Try this: private function htmlEscape(str:String):String { return XML(new XMLNode(XMLNodeType.TEXT_NODE, str)).toXMLString(); }
It uses the legacy ActionScript 2 object. I don't know how long this will stay around but it is included in the latest 3.5SDK (Not sure about 4). HTH Steve --- In flexcoders@yahoogroups.com, Peter Valdemar Mørch <li...@...> wrote: > > Hi, I didn't get any replies, so here is a polite bump... > > My question is basically this: How do I create an XML node with a > toXMLString() value of: > > <value>a <foo>string</foo>/&</value> > > from a value of > > var value:String = "a <foo>string</foo>/&"; > > Is this really something one is expected to code by hand using RegExp > or split&join? Isn't this something everybody who needs to send / > recieve XML needs to be safe? I just can't find it anywhere. > > Also, I wrote: > > P.S.: Please don't tell me about escape() because it URL-encodes, > > which is not the same thing. (For "a&b" I want "a&b", not > > "a%26b). > > Sorry if this offended anyone. I didn't mean to be rude. > > Peter > -- > Peter Valdemar Mørch > http://www.morch.com >