开发者

Sort simplexml object - without casting to array

开发者 https://www.devze.com 2023-04-06 01:14 出处:网络
Is it possible to sort a simplexml object but keep the object as a simplexml object instead of casting to an array.

Is it possible to sort a simplexml object but keep the object as a simplexml object instead of casting to an array.

There doesnt appear to be a way to do this - and if casted to an array it seems very messy to transform the array(s) back to a simplexml object.

So -

Is it possible to sort a simplexml object by an attribute etc.

For example (sort by the position attribute node):

&l开发者_如何学编程t;test_nodes>
  <node position="1"></node> 
  <node position="2"></node> 
  <node position="3"></node> 
</test_nodes>

If not then what is the most painless and efficient way to cast an array to a simple xml object

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号