-
When I retreive data from a file (demo.xml) flash interprets "\n" and TABs as a childnode.
That makes it hard for me to handle the date.
Is this a known problem?
Is ther a solution?
Or is it a "I-am-to-stupit"-problem, than please clue me?!
XML as a CGI-output is no problem, but I like to avoid writing all my xml-files in a single-Line...
-
Senior Member
this is a problem with Flash reading whitespace as nodes, you need to parse the white space out.
moock has written this function to do it for you:
Code:
function cutWhitespace (xmlObjectToParse) {
for (var i = 0; i < xmlObjectToParse.childNodes.length; i++) {
if (xmlObjectToParse.childNodes[i].nodeType == 3) {
var j = 0;
var empty = true;
for (j=0; j<xmlObjectToParse.childNodes[i].nodeValue.length; j++) {
if (xmlObjectToParse.childNodes[i].nodeValue.charCodeAt(j)>32) {
empty = false;
}
break;
}
}
if (empty) {
xmlObjectToParse.childNodes[i].removeNode();
}
for (var k = 0; k < xmlObjectToParse.childNodes.length; k++) {
var cutSubNodes = xmlObjectToParse.childNodes[k];
cutWhitespace(cutSubNodes);
}
}
}
-
Not broken - this is the way XML works
[QUOTE]Originally posted by schwani
[B]When I retreive data from a file (demo.xml) flash interprets "\n" and TABs as a childnode.
That makes it hard for me to handle the date.
Is this a known problem?
The XML DOM is defined so that whitespace _is_ important. That means it gets its own node, and all of the problems that you have mentioned. You can parse it out, or there is a property that allows you to tell certain versions of the player to ignore whitespace.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|