0
我是xml的新手,並且在瀏覽器中查看時會遇到一些問題。我的XML結構如下:屬性的XML切換順序
<?xml version="1.0" encoding="UTF-8"?>
<GamesSuites>
<Suites>
<Suite Name="Favorites" ID="Favorites">
<Games>
<Game Name="Lucky 7" ID="2" ImagePath="#images/Provider_11_1/Games/casinoGames_01.jpg"/>
<Game Name="Diamond Jackpot" ID="32" ImagePath="#images/Provider_11_1/Games/casinoGames_02.jpg"/>
<Game Name="Royal Reels" ID="223" ImagePath="#images/Provider_11_1/Games/casinoGames_03.jpg"/>
<Game Name="Safari Sam" ID="280" ImagePath="#images/Provider_11_1/Games/casinoGames_04.jpg"/>
<Game Name="Treasure Room" ID="158" ImagePath="#images/Provider_11_1/Games/casinoGames_05.jpg"/>
<Game Name="Aztec Treasures" ID="190" ImagePath="#images/Provider_11_1/Games/casinoGames_06.jpg"/>
</Games>
</Suite>
</Suites>
</GamesSuites>
當雖然名稱和ID屬性交換左右在瀏覽器中查看。 所以在瀏覽器中查看時,它看起來像這樣:
<?xml version="1.0" encoding="UTF-8"?>
<GamesSuites>
<Suites>
<Suite Name="Favorites" ID="Favorites">
<Games>
<Game ID="2" Name="Lucky 7" ImagePath="#images/Provider_11_1/Games/casinoGames_01.jpg"/>
<Game ID="32" Name="Diamond Jackpot" ImagePath="#images/Provider_11_1/Games/casinoGames_02.jpg"/>
<Game ID="223" Name="Royal Reels" ImagePath="#images/Provider_11_1/Games/casinoGames_03.jpg"/>
<Game ID="280" Name="Safari Sam" ImagePath="#images/Provider_11_1/Games/casinoGames_04.jpg"/>
<Game ID="158" Name="Treasure Room" ImagePath="#images/Provider_11_1/Games/casinoGames_05.jpg"/>
<Game ID="190" Name="Aztec Treasures" ImagePath="#images/Provider_11_1/Games/casinoGames_06.jpg"/>
</Games>
</Suite>
</Suites>
</GamesSuites>
這究竟是爲什麼?
因爲瀏覽器會解析您的XML代碼並嘗試以某種不變的順序輸出它。這不是錯誤或什麼。 – Justinas 2014-08-28 11:54:44
瀏覽器如何顯示XML並不重要。每當你想操縱XML時,你總是會使用屬性名稱(「name」或「Id」..等)來獲取值。 – Andromeda 2014-08-28 11:55:12
啊,好吧。感謝您的解釋 – Mikey 2014-08-28 11:58:17