Note that there are some explanatory texts on larger screens.

plurals
  1. POPython ElementTree duplicate checker
    primarykey
    data
    text
    <p>So I have to write a "duplicate checker" to compare two XMLs and see if they are the same (contain the same data). Now because they come from the same class and are generated form an XSD the structure the order of the elements inside will most likely be the same.</p> <p>The best way I can think of doing the duplicate check is to set up two dictionaries (dictLeft, dictRight) and saving the xpath#value as the key and the number of times it occurs. Something like this:</p> <p>Left:</p> <pre><code>{ 'my/path/to/name#greg': 1, 'my/path/to/name#john': 2, 'my/path/to/car#toyota': 1} </code></pre> <p>Right</p> <pre><code>{ 'my/path/to/name#greg': 1, 'my/path/to/name#bill': 1, 'my/path/to/car#toyota': 1} </code></pre> <p>Comparing these two dictionaries will give me a fairly accurate indication of whether or not these two XMLs are the same or not (there is the odd chance that I may get false results, but it is very remote).</p> <p>Does anyone else have a better idea? Maybe a function in ElementTree that I do not know about?</p> <p>EDIT: To better explain:</p> <pre><code>&lt;root&gt;&lt;person&gt;&lt;name&gt;Bob&lt;/name&gt;&lt;surname&gt;marley&lt;/surname&gt;&lt;/root&gt; </code></pre> <p>and</p> <pre><code>&lt;root&gt;&lt;person&gt;&lt;surname&gt;marley&lt;/surname&gt;&lt;name&gt;Bob&lt;/name&gt;&lt;/root&gt; </code></pre> <p>would be considered the same. I am ignoring attributes. The idea is to keep the code as simple as possible while not hampering performance too much.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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