Skip navigation
Babulal
Currently Being Moderated

Load XML in HTML control

Dec 26, 2013 5:01 AM

Tags: #flex #html #htmlloader

Hi,

 

I am using HTML control to show the stylesheet included XML. when i alert the body of HTML control, it show HTML formatted content mentioned below in OUTPUT.

 

  1. I need exact XML Content instead of HTML Content.
  2. If i select the content in HTML ("Empire") then i need to get the extact xml node.

 

I need Solution or samples or references for the above issue.

 

HTMLTest.mxml

 

<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                       xmlns:s="library://ns.adobe.com/flex/spark"

                       xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init()">   

    <fx:Script>

        <![CDATA[

            import flashx.textLayout.tlf_internal;           

            import mx.controls.Alert;

           

            private function init():void{

                html.htmlLoader.navigateInSystemBrowser = true

                html.location = "file:///E:/Share/Changes/test.xml";

            }

           

            private function check():void{

                Alert.show("test");

                Alert.show(html.location);               

                var body:String = html.htmlLoader.window.document.body.outerHTML;               

                Alert.show(body);

            }

           

        ]]>

    </fx:Script>

    <mx:VDividedBox>       

        <mx:Button id="btn" label="Check" x="200" y="10" width="100" click="check()">

           

        </mx:Button>

        <mx:HTML id="html" x="10" y="100" width="1000" height="500">

           

        </mx:HTML>

    </mx:VDividedBox>

</s:WindowedApplication>

 

 

test.xml

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Edited by XMLSpy® -->

<?xml-stylesheet href="test.xsl" type="text/xsl" ?>

<catalog>

    <cd>

        <title>Empire Burlesque</title>

        <artist>Bob Dylan</artist>

        <country>USA</country>

        <company>Columbia</company>

        <price>10.90</price>

        <year>1985</year>

    </cd>

    <cd>

        <title>Hide your heart</title>

        <artist>Bonnie Tyler</artist>

        <country>UK</country>

        <company>CBS Records</company>

        <price>9.90</price>

        <year>1988</year>

    </cd>

    <cd>

        <title>Greatest Hits</title>

        <artist>Dolly Parton</artist>

        <country>USA</country>

        <company>RCA</company>

        <price>9.90</price>

        <year>1982</year>

    </cd>   

</catalog>

 

 

test.xsl

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Edited by XMLSpy® -->

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 

<xsl:template match="/">

  <html>

  <body>

  <h2>My CD Collection</h2> 

  <xsl:apply-templates/> 

  </body>

  </html>

</xsl:template>

 

<xsl:template match="cd">

  <p>

    <xsl:apply-templates select="title"/> 

    <xsl:apply-templates select="artist"/>

  </p>

</xsl:template>

 

<xsl:template match="title">

  Title: <span style="color:#ff0000">

  <xsl:value-of select="."/></span>

  <br />

</xsl:template>

 

<xsl:template match="artist">

  Artist: <span style="color:#00ff00">

  <xsl:value-of select="."/></span>

  <br />

</xsl:template>

 

</xsl:stylesheet>

 

 

Output:

<body>

<h2>My CD Collection</h2>

    <p>

  Title: <span style="color:#ff0000">Empire Burlesque</span><br>

  Artist: <span style="color:#00ff00">Bob Dylan</span><br></p>

    <p>

  Title: <span style="color:#ff0000">Hide your heart</span><br>

  Artist: <span style="color:#00ff00">Bonnie Tyler</span><br></p>

    <p>

  Title: <span style="color:#ff0000">Greatest Hits</span><br>

  Artist: <span style="color:#00ff00">Dolly Parton</span><br></p>

  </body>

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points