The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • Flash Professional
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 Flash Professional

  • Luke-F Author 
    • 3148 
    • 0 
    • 4 
    (AS2) XML - convert < to read as HTML

    Last reply Mar 26 2009, 12:05 PM

    by

    Posted: Mar 25 2009, 01:38 PM

    by Luke-F

     

Hi,
I’m bringing in some XML from a PHP generated page. unfortunately they PHP generates the XML as follows:

<moreInfo><b>Abstract Painting</b><br />1963<br />170.00 x 215.00
 cm
<br />Oil on canvas<</moreInfo> 

Rather than processing and reading the data as HTML, flash will print this out as html:

<b>Abstract Painting</b><br />1963<br />170.00 x 215.00 cm<br />Oil on canvas<br /> 

I’m using AS2, a HTML enabled text field and i’ve tried the unescape/escape function. It looks like unescape will only work on hexadecimal data.

Any ideas on how to get flash to read this as html?

Cheers,
Luke.

  4 REPLIES
 
chrismann
1  
chrismann

Edited (I found a possible solution)

Here’s a test I ran

var m:String= "<items><one>plain</one><two><![CDATA[this is <i>italic</i>]]></two></items>";
var 
my_xml:XML = new XML(m);
trace("using firstChild:");
for (var 
i = 0; i<my_xml.firstChild.childNodes.length; i++) {
    trace
("\t"+my_xml.firstChild.childNodes[i].firstChild);
}
trace
("");
trace("using firstChild.nodeValue:");
for (var 
i = 0; i<my_xml.firstChild.childNodes.length; i++) {
    trace
("\t"+my_xml.firstChild.childNodes[i].firstChild.nodeValue);
} 

Output is

using firstChild:
    
plain
    this is 
<i>italic</i>

using firstChild.nodeValue:
    
plain
    this is 
<i>italic</i> 
  • 25 March 2009 03:54 PM
  •  
tiran
2  
tiran

As you found out, the problem is not how PHP interprets the page, its how Flash does. Take a look at your raw php generated XML in a browser and you will not see those characters. nodeValue is the solution you are looking for.

  • 25 March 2009 04:23 PM
  •  
Luke-F Author 
3  
Luke-F

Thanks for your help, this is looking good. It’s returning “null” at the moment. Can you figure out what’s happening? Here’s what I’ve got:


AS2

[AS]moreInfoTxt.htmlText = mainNode.childNodes[moreInformation].childNodes[0].nodeValue[/AS]


XML:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<songs>
    <
song trackTitle="track tite1">  
        <
moreInfo><![CDATA[ <b>Abstract Painting</b><
br />1963<br />170.00 x 215.00 cm<br />Oil on canvas<
br />Catalogue Raisonné: 144<br />Collection: K21 Kunstsammlung, 
Düsseldorf, Germany<br />Audio courtesy of <u><
a href='http://:www.acoustiguide.com' target='_blank'>
Acoustiguide</a></u>]]></moreInfo>
    </
song>
</
songs> 

(I’ve broken the xml apart so the forum page holds together)

  • 26 March 2009 06:52 AM
  •  
Luke-F Author 
4  
Luke-F

Hi,
All fixed! Thanks for your help. I out that i was declaring a var that messed with it. Basically, nodeValue worked a treat.

Thanks UShock team.


full solution:
mainNode.childNodes[moreInformation].childNodes[0].nodeValue.split(”<”).join(”<”).split(”>”).join(”>”);

  • 26 March 2009 12:05 PM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 775  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,724  Assets
  • Profiles 282,659  Members
  • Topics 93,762  Topics
  • Blog 4  Blog
  • Facebook 1,680  Facebook
  • Twitter 1,165  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 04, 2012 - 20:08:11