If you are sorting for display you dont need to sort and rebuild the XML tree at all. Just iterate over the node parent according to the X then Y attributes of the <location> child. If you really want to sort your file and save, then I think the simplest way would be to build a new tree and add in nodes as they are sorted. Then save your new xml tree over the top of the old.
I find Xpath easier to bend my mind around so I have been using XML::LibXML which gives you the option of mixing and matching between XPath and DOM according to the task.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|