Skip to main content
Inspiring
June 26, 2008
Answered

Flash Changes XML data

  • June 26, 2008
  • 3 replies
  • 541 views
Hi all,

Any reason why the attached code would yield this in a trace?
<comments>
<mastercomment1/>
<mastercomment2/>
<mastercomment3/>
<mastercomment4/>
</comments>

Your thoughts are much appreciated...
-SyddyS
This topic has been closed for replies.
Correct answer SyddyS
OK...

Thanks for the help, Rothrock. Yep, we're in AS3. Here's the combo of fun that makes it happen:
XML.prettyPrinting = false;
XML.ignoreWhitespace = false;

This lets the tabs that FCP seems to love so much shine through, and things are almost working. That combo of prettyPrinting (nice) and ignoreWhitespace allows an imported XML file to retain any tab characters it may have in it without converting them to spaces. The file now imports into Final Cut, and I have a brand spanking new title created dynamically by Flash.

The one remaining hurdle to this project is that many titles have more than one line. When XML is exported from Final Cut, it codes the linebreak as &#13; (just in case it gets decoded here, that's ampersand poundsign 13 semicolon. If you type that particular combination into Google, it thinks you typed a linefeed :P ). Flash, being a slave to the All-Powerful Ampersand, turns any ampersand I may try and include in a node value into &amp. Final Cut, not surprisingly, has no idea what &amp means.

Any way to get Flash to use an ampersand in an XML node? I tried using nodeValue, but that doesn't seem to work in AS3 as it did in AS2.

Thanks,
SyddyS


3 replies

Inspiring
June 26, 2008
I would think you would want to set it to true, but I see that is the default. You are using AS3, right?

Are you using prettyIndent()? Can FCP import XML that has absolutely no white space between nodes?
SyddySAuthorCorrect answer
Inspiring
June 26, 2008
OK...

Thanks for the help, Rothrock. Yep, we're in AS3. Here's the combo of fun that makes it happen:
XML.prettyPrinting = false;
XML.ignoreWhitespace = false;

This lets the tabs that FCP seems to love so much shine through, and things are almost working. That combo of prettyPrinting (nice) and ignoreWhitespace allows an imported XML file to retain any tab characters it may have in it without converting them to spaces. The file now imports into Final Cut, and I have a brand spanking new title created dynamically by Flash.

The one remaining hurdle to this project is that many titles have more than one line. When XML is exported from Final Cut, it codes the linebreak as &#13; (just in case it gets decoded here, that's ampersand poundsign 13 semicolon. If you type that particular combination into Google, it thinks you typed a linefeed :P ). Flash, being a slave to the All-Powerful Ampersand, turns any ampersand I may try and include in a node value into &amp. Final Cut, not surprisingly, has no idea what &amp means.

Any way to get Flash to use an ampersand in an XML node? I tried using nodeValue, but that doesn't seem to work in AS3 as it did in AS2.

Thanks,
SyddyS


Inspiring
June 26, 2008
Yeah it is a good trick to make hand typed XML easier or to make reading machine generated XML easier. You can still have attributes:

<mastercomment id="1" />

That is strange. I would think the problem was more with Final Cut Pro. Ideally XML shouldn't rely on how it is laid out to parse and be read correctly. What happens if you use ignorewhite in Flash and just get rid of all the tabs and spaces all together?
SyddySAuthor
Inspiring
June 26, 2008
No love on just setting ignoreWhitespace to false. FCP must just have a jones when it comes to TABs. I'm SO very close to having a Flash application that can dynamically create titles (or just about anything else for that matter, thanks to XML) for Final Cut. I feel like I'm just a couple small obstacles away...
Inspiring
June 26, 2008
Why not? It is a bit strange that Flash changes it, but as far as I know the result is perfectly valid for a node that contains no other data. You'll notice that the comment node is left as it was because it contains other nodes.

Is this causing some problem?
SyddySAuthor
Inspiring
June 26, 2008
Hi Rr,

Thanks for getting back so quickly. I'm pretty new to XML and it's probably obvious. I was unaware that the <something/> was a legit way of saying "Gotta node here, but there ain't nothing in it" (if I'm understanding you right). And you're right, though I thought it was a problem, it isn't.

Right disease, wrong symptom- basically my exported XML (using Zinc) was causing the destination program (Final Cut Pro) to barf when my XML file was imported. Even just loading in Flash and then re-saving, unaltered, was causing it to not recognize the file. As this was the only visible difference between the IN and the OUT, I mistakenly thought it was the alterations done to these tags.

What ACTUALLY is the problem is that Flash converts the tabs to spaces (which of course you can't see in trace, or in your standard view text editor). After reading your post, I went through my outputted file with a fine toothed comb and painstakingly replaced all the spaces with proper TABs. Bingo- it imported fine.

Soooo... the NEW QUESTION is, any way to make Flash use tabs instead of spaces in its handling of XML?

The topic's still good, as Flash is (technically) changing my XML data :)

Thanks,
SyddyS