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:
<SERVICES>
<RELATIONSHIPS>
<RELATIONSHIP xlink:from="fromValue01" xlink:to="toValue01" />
<RELATIONSHIP xlink:from="fromValue02" xlink:to="toValue02" />
<RELATIONSHIP xlink:from="fromValue03" xlink:to="toValue03" />
<RELATIONSHIP xlink:from="fromValue04" xlink:to="toValue04" />
<RELATIONSHIP xlink:from="fromValue05" xlink:to="toValue05" />
<RELATIONSHIP xlink:from="fromValue06" xlink:to="toValue06" />
<RELATIONSHIP xlink:from="fromValue07" xlink:to="toValue07" />
</RELATIONSHIPS>
<SERVICES>
Now, when I want to add more of these RELATIONSHIP nodes with same attributes but with different values (e.g. <RELATIONSHIP xlink:from="fromValue08" xlink:to="toValue08" />) I always get a Duplicate Attribute error. This would be example of the xpath I’m parsing:
/SERVICES/RELATIONSHIPS/RELATIONSHIP[@xlink:from="fromValue08" and @xlink:to="toValue08"]
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.
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?
It’s sure in relation with your XPath request maybe an index in missing for
RELATIONSHIPS