My question is how to set values to two attributes that have the same name but different namespaces.
Using C#, in an XML document, I need to assign two attributes to an element. It should look like
doc xmlns:xmi="uriaddress" element xsi:type="xsitype1" type="type1"
I tried
xElement.SetAttribute("type","uriaddress","xsitype1")
this works fine!
however, my surprise is that when I tried to set the second attribute, "type", by
xElement.SetAttribute("type","type1")
this works, but it also resets the attribute xmi:type to the same value as attribute "type", changing the element in an unintended way.
Now the element looks like
element xsi:type="type1" type="type1"
Any way to get around this?
Seems to me like you put the wrong namespace in the first SetAttribute call. That namespace should be the namespace for the xsi prefix, not for the xmi prefix...
You may just be trying to demonstrate the problem, so I might have gotten the wrong idea here
Hope that helps