XML切换属性顺序

时间:2014-08-28 11:51:29

标签: 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>

为什么会这样?

1 个答案:

答案 0 :(得分:0)

根据定义,XML元素的属性是无序键/值对的集合。 XML解析器不需要保留源中给出属性的顺序,并且消耗XML的应用程序不关心该订单是什么。