这是我现在的xml。可以添加新的“项目”节点,我希望所有节点都按类别 ID 排序。
<?xml version="1.0" encoding="utf-8"?>
<data>
<banners>
<banner type="search-bar">
<item img="http://site.com/3ac0a.png" id="5df129a6-1" categoryid="7" />
<item img="http://site.com/3ac1a.png" id="5df129a6-1" categoryid="10" />
<item img="http://site.com/3ac2a.png" id="dfgsdfgg-1" categoryid="1" />
<item img="http://site.com/3ac3a.png" id="5erjrthr-1" categoryid="2" />
<item img="http://site.com/3ac4a.png" id="yuj67445-1" categoryid="3" />
<item img="http://site.com/3ac5a.png" id="ghjmdmgh-1" categoryid="4" />
</banner>
</banners>
</data>
像这样
<?xml version="1.0" encoding="utf-8"?>
<data>
<banners>
<banner type="search-bar">
<item img="http://site.com/3ac2a.png" id="dfgsdfgg-1" categoryid="1" />
<item img="http://site.com/3ac3a.png" id="5erjrthr-1" categoryid="2" />
<item img="http://site.com/3ac4a.png" id="yuj67445-1" categoryid="3" />
<item img="http://site.com/3ac5a.png" id="ghjmdmgh-1" categoryid="4" />
<item img="http://site.com/3ac0a.png" id="5df129a6-1" categoryid="7" />
<item img="http://site.com/3ac1a.png" id="5df129a6-1" categoryid="10" />
</banner>
</banners>
</data>
我需要保存已排序的 XML