Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting after a Node with XmlWriter
    text
    copied!<p>I'm low on documentation about XmlReader, I have an structure for a node that looks like this</p> <pre><code>&lt;person key="17000000"&gt; &lt;name&gt;John Doe&lt;/name&gt; &lt;age&gt;23&lt;/age&gt; &lt;/person&gt; </code></pre> <p>And a file containing a group of people, that must be ordered by key.</p> <pre><code>&lt;group&gt; &lt;person key="123"&gt; ... &lt;/person&gt; &lt;person key="130"&gt; ... &lt;/person&gt; &lt;/group&gt; </code></pre> <p>I'm writing a function that inserts them in the correct order but I'm having issues telling the place where a new person must be inserted. So far I'm doing the following:</p> <ol> <li>Create reader for the group file and a writer for a temporary file.</li> <li>Read until reader's key is bigger than request's key, write nodes to temp while reading.</li> <li>Write the request structure to the temp file.</li> <li>Read the rest of the file and write to the temp file.</li> <li>Replace the group file with the temp file.</li> </ol> <p>So far is not working, and the file is looking like this (if 130 is inserted after 123):</p> <pre><code>&lt;group&gt; &lt;group&gt; &lt;person key="123"&gt; ... &lt;/person&gt; &lt;/group&gt; &lt;person key="130"&gt; ... &lt;/person&gt; &lt;/group&gt; </code></pre> <p>Is there a general way to insert structures in Xml files? </p> <p>I have some restrictions, like, I must use XmlReader and XmlWriter and memory usage is limited, so I can work with a reader and writer pointer and that's it.</p> <p>I appreciate your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload