Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How can I set the 'SetAttributeValue' and d2p1:type in xml generated from XElement

$
0
0

Greetings,

I am receiving xml that is a serialized .net object in xml form.  The issue is that I when I try to create an xml similar to the serialized object, the attributes do not seem to match quite right using XElement.

Example:  (This is a subset of actual data and what I want it to look like, and the object serialized is called - MyTestData)       <anyType d2p1:type="MyTestData">
    <Name>Test</Name>
    <Description>Development</Description>
   </anyType>

I try to specify the type as described above for the "d2p1:type",but  as far as I can tell the ":" is not a valid character.

What I tried using the below, it throws an exception on the ":" symbol. 

newNode.SetAttributeValue("d2p1:type","MyTestData");

If I try the following below it puts extra items in the list which I do not need.

XNamespace aw ="d2p1";
newNode.SetAttributeValue(aw +"type","MyTestData");

This is what it generates:

  <anyType p5:type="MyTestData" xmlns:p5="d2p1">

What I need to be generated:<anyType d2p1:type="MyTestData">

Thanks for any suggestions!


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>