•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Graphics and Multimedia section within the Web Development category of DaniWeb, a massive community of 391,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,175 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Graphics and Multimedia advertiser:
Views: 3094 | Replies: 5
![]() |
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Rep Power: 0
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
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,142
Reputation:
Rep Power: 10
Solved Threads: 258
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)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,142
Reputation:
Rep Power: 10
Solved Threads: 258
•
•
•
•
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]
If you don't mind, can you explain line-by-line what you are doing?
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)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Rep Power: 0
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Graphics and Multimedia Marketplace
•
•
•
•
animations api asp blogger blogging code dell development dom feed files flash flash flv gdata google graphics hard drive hardware html ie7 intel laptop linspire linux media microsoft multimedia news nvidia open-source opengl openoffice peripherals photoshop preview programming reader rss sandisk scripting security standards streaming video w3c weather web xml xoap
- 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?



Linear Mode