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