Hi all,

I'm working with httpservice and a rich text area. I pull in the xml via 
httpservice, then parse out all xml tags. However, dependent on the XML I need 
to do various things, such as if the text is in an <boldMe> tag, then make it 
bold; if it's in an <italicizeMe> tag, then I'll italicize it, then display it, 
correctly formatted, in the RTE.

Questions:
1) I need to have the <P> tags create new lines. Not sure how to do that 
without kludgy regular expressions. That can't be the best way. Can it? :)
2) I want to keep the whitespace, but as you'll see that isn't happening.

Thanks,

David

*******************************************
Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml"; 
    width="900" height="800"    
    initialize="initializeHandler();"
>

    <mx:Script>
        <![CDATA[
                import mx.rpc.events.ResultEvent;
                import flash.text.TextFormat;
        
            [Bindable] public var xData:XML; 
  
            private function initializeHandler():void

            {
                                bt.send();
            }
            
            private function btRPCResult(event:ResultEvent):void
            {
                xData = event.result as XML;
                xData.ignoreWhitespace = false;
            }

            private function showTest():void {
                outField.text = "";
                                for each (var item:XML in xData.Content.P.*) {
                                //here's where I want to conditionally act upon 
the text of boldMe, italicizeMe, etc.
                                outField.text += item;
                                }
                         }

        ]]>
    </mx:Script>

    <mx:HTTPService id="bt" url="test.xml" result="btRPCResult(event)" 
resultFormat="e4x"/>

    <!-- User interface -->
        <mx:ApplicationControlBar dock="true">

                <mx:Button label="Show Test Story" click="showTest()" />
        </mx:ApplicationControlBar>
        <mx:TextArea id="outField" width="100%" height="100%"
                  text="{xData.toString()}" />
</mx:Application>

test.xml:

<Text>
        <Content>
                <P>
                The quick <boldMe>brown</boldmMe> 
                        <italicizeMe>fox</italicizeMe> jumps over the 
<boldMe>lazy</boldMe> dog.
                </P>
                <P>
                        Now is the time for all <boldMe>good</boldMe> men to 
come to the aid of their <italicizeMe>country</italicizeMe>.
                </P>
        </Content>
</Text>

Reply via email to