台灣最大程式設計社群網站
線上人數
957
 
會員總數:246272
討論主題:189809
歡迎您免費加入會員
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
XML 問題
價值 : 10 QP  點閱數:1858 回應數:5
樓主

mandog
初學者
69 118
1194 135
發送站內信

XML 1 :
<?xml version="1.0" standalone="yes"?>
<gallery>
<image>
<title>Balanced Breakfast</title>
<main>images/breakfast.jpg</main>
<thmb>thumbnails/breakfast.jpg</thmb>
</image>
</gallery>
----------------------------------------------------------------------------------------------------------------------------
XML 2:
<?xml version="1.0" standalone="yes"?>
<gallery>
<image title="Balanced Breakfast" main="images/breakfast.jpg" thmb="thumbnails/breakfast.jpg"/>
</gallery>
----------------------------------------------------------------------------------------------------------------------------
Flash AS:
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};
myPhoto.load("xml.xml");

---------------------------------------------------------------------------------------------------------------------------
為何XML 2 可以 run. 但XML 1 拿不出data??

本篇文章發表於2005-12-28 15:19
1樓
回應

abgne
捐贈 VP 給 abgne 檢舉此回應
因為XML 2的都寫在屬性裡面...且你actionscript都是抓屬性的值
但你XML 1的都是改成用node...所以會抓不到
本篇文章回覆於2005-12-28 17:03
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
回應

東之月
檢舉此回應
@@ .... 可以讀的只是妳讀到Attributes .... 如果要讀子結構要用
var firstTree:XMLNode = this.m_xml.firstChild.firstChild;
var SecordTree:XMLNode = firstTree.firstChild;
這樣SecordTree就會是你的一個<tag>value</tag> ....... ^^
本篇文章回覆於2005-12-28 17:40
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
3樓
作者回應

mandog
檢舉此回應
可否幫我用以下例改改...我概念很不清喲...thanks
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};
myPhoto.load("xml.xml");
本篇文章回覆於2005-12-28 17:50
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
4樓
最有價值解答

泡夢
捐贈 VP 給 白果喵 檢舉此回應
以xml1的架構,應該是這樣讀取的。
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.childNodes[2].firstChild.nodeValue);
this.thumbHolder.title = this.picHolder.childNodes[0].firstChild.nodeValue;
this.thumbHolder.main = this.picHolder.childNodes[1].firstChild.nodeValue;
this.thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};
myPhoto.load("xml.xml");
本篇文章回覆於2006-01-05 11:56
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
5樓
作者回應

mandog
檢舉此回應
let me try~~
You are so helpful~~~
thank you
本篇文章回覆於2006-01-05 14:07
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.