Note that there are some explanatory texts on larger screens.

plurals
  1. PODuplicate error when adding XAttribute to XElement
    text
    copied!<p>I've got a big xml file and I'm parsing an xpath to insert values in it. This is a part of the xml file where I'm inserting some values:</p> <pre><code>&lt;SERVICES&gt; &lt;RELATIONSHIPS&gt; &lt;RELATIONSHIP xlink:from="fromValue01" xlink:to="toValue01" /&gt; &lt;RELATIONSHIP xlink:from="fromValue02" xlink:to="toValue02" /&gt; &lt;RELATIONSHIP xlink:from="fromValue03" xlink:to="toValue03" /&gt; &lt;RELATIONSHIP xlink:from="fromValue04" xlink:to="toValue04" /&gt; &lt;RELATIONSHIP xlink:from="fromValue05" xlink:to="toValue05" /&gt; &lt;RELATIONSHIP xlink:from="fromValue06" xlink:to="toValue06" /&gt; &lt;RELATIONSHIP xlink:from="fromValue07" xlink:to="toValue07" /&gt; &lt;/RELATIONSHIPS&gt; &lt;SERVICES&gt; </code></pre> <p>Now, when I want to add more of these <code>RELATIONSHIP</code> nodes with same attributes but with different values (e.g. <code>&lt;RELATIONSHIP xlink:from="fromValue08" xlink:to="toValue08" /&gt;</code>) I always get a <code>Duplicate Attribute</code> error. This would be example of the xpath I'm parsing:</p> <pre><code>/SERVICES/RELATIONSHIPS/RELATIONSHIP[@xlink:from="fromValue08" and @xlink:to="toValue08"] </code></pre> <p>The parser is too big of a code to just paste here, and I'm sure it's working fine since it's inserting all nodes just fine, only this part here is giving me some trouble. I also checked the xpath with Altova and it works.</p> <p>My question is: Is adding a node with same attributes but with different values allowed in XML? And if yes, why is Visual Studio always throwing this error?</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