| | |
Flash & XML: skipping past 2nd XML Declaration
Please support our Graphics and Multimedia advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Solved Threads: 0
I'm using Flash 8 Pro to parse a Microsoft Excel file saved as XML. Excel 2002 had only the standard XML Declaration line:
[PHP]<?xml version="1.0"?>
<Workbook ...>...</Workbook>[/PHP]
However, Excel 2003 now has two XML Declaration lines:
[PHP]<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook ...><...</Workbook>[/PHP]
Everything works fine if I delete the 2nd XML Declaration line, but I'm hoping to not require this of my users whenever they save a new Excel file as XML. I tried the following code w/out success:
[PHP]var xmlVal
ML = new XML();
xmlVal.ignoreWhite = true;
xmlVal.load("myFile.xml");
xmlVal.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
var xmlWorkbook
MLNode = xmlVal.firstChild;
while (xmlWorkbook.nodeName != "Workbook")
xmlWorkbook = xmlWorkbook.nextSibling;
}
}[/PHP]
The problem is that "xmlVal.firstChild" points to "undefined" if the 2nd XML Declaration line exists. Any help would be greatly appreciated...
Thanks ahead of time.
~Nate
[PHP]<?xml version="1.0"?>
<Workbook ...>...</Workbook>[/PHP]
However, Excel 2003 now has two XML Declaration lines:
[PHP]<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook ...><...</Workbook>[/PHP]
Everything works fine if I delete the 2nd XML Declaration line, but I'm hoping to not require this of my users whenever they save a new Excel file as XML. I tried the following code w/out success:
[PHP]var xmlVal
ML = new XML();xmlVal.ignoreWhite = true;
xmlVal.load("myFile.xml");
xmlVal.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
var xmlWorkbook
MLNode = xmlVal.firstChild;while (xmlWorkbook.nodeName != "Workbook")
xmlWorkbook = xmlWorkbook.nextSibling;
}
}[/PHP]
The problem is that "xmlVal.firstChild" points to "undefined" if the 2nd XML Declaration line exists. Any help would be greatly appreciated...
Thanks ahead of time.
~Nate
I'm not in Flash programming, but principle is gone be same for all programming. Try to search for first association of "Workbook" and read from that point on or assume that this work on principle read line-by-line do an if statement to check for read content if that is
<?mso-application progid="Excel.Sheet"?>
than ignor it and read next line
<?mso-application progid="Excel.Sheet"?>
than ignor it and read next line
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
•
•
Originally Posted by ignitrix
[PHP]var xmlValML = new XML();
xmlVal.ignoreWhite = true;
xmlVal.load("myFile.xml");
xmlVal.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
var xmlWorkbookMLNode = xmlVal.firstChild;
while (xmlWorkbook.nodeName != "Workbook")
xmlWorkbook = xmlWorkbook.nextSibling;
}
}[/PHP]
What I understand/gues is
1)declaring variable to hold xml
2)you ignore white space
3)loading in xml file
4)checking if document loaded properly
5) if yes continue with
a)assign value of xmlVal.firstChild to var on other side {what is firstChild any declaration/description?}
b)while you do not find Workbook repeat { does it already passed first workbook?}
c)asuming this is reading part - reading from xml
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Solved Threads: 0
I figured out the solution to my problem (thanks astgtciv). I basically just run a cleanup script to remove the bad DTD line before parsing. The following code will do this:
~Nate
Graphics and Multimedia Syntax (Toggle Plain Text)
XML myxml = new XML(); myxml.onData = function (src:String) { if (src == undefined) { this.onLoad(false); } else { src = cleanUp(src); this.parseXML(src); this.loaded = true; this.onLoad(true); } } function cleanUp(src:String):String { var sStringToRmv:String = "<?mso-application progid=\"Excel.Sheet\"?>"; var nBadStrLoc:Number = src.indexOf(sStringToRmv, 0); if (nStrLoc >= 0) src = src.slice(0, nBadStrLoc) + src.slice(nBadStrLoc+sStringToRmv.length, src.length); return src; }
~Nate
Good, that is what I was trying say to you
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- ActionScript XML and a good XML Editor (RSS, Web Services and SOAP)
- saving xml file from servlet request instance (Java)
- HTML & XML (HTML and CSS)
- HTML & XML (HTML and CSS)
Other Threads in the Graphics and Multimedia Forum
- Previous Thread: picture usage...
- Next Thread: Gimp?
| Thread Tools | Search this Thread |
3d 10 actionscript3 adobe adobeacrobat adobereader air ajax amazon amf apple button cart childprotection cloud dashboard dell design dojofoundation dreamweaver ebay eclipse ecommerce elasticcomputecloud embed endorsement extra family flash flash-develop flashlite flex free harddrive iamthwee ibm illustrator imflash intel interactivemap javafx javascript laptop legal map micron microsoft mobile monitoringsoftware moonlight multimedia myspace nand news novell panorama pdf pedophiles photoshop photosynth php safety sandisk security shopping silverlight solidstatedrive sproutcore ssd streaming swf table ukmap unload unwanted video vulnerability web white.space xml zend zephyr zeroday






