I'm working on an historical script which I have limited knowledge of.
Object A is of type system.xml.xmlelement and I need to convert this to type system.xml.xmldocument to do a comparison with Object B (type system.xml.xmldocument).
The script currently tries to do a direct conversion which throws with:
Cannot convert value
System.Xml.XmlElementto typeSystem.Xml.XmlDocument. Error: "The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type."
I think I need to create a new system.xml.xmldocument object and import the node from object A into the new object and then do the comparison on the new object with object B. I'm struggling with the correct syntax, plus I'm not sure this is the correct approach.
Any guidance or help would be appreciated.
Object A (xmlElement) looks like this:
<Resource xmlns="http://schemas.microsoft.com/windowsazure">
<ResourceProviderNamespace>cacheservice</ResourceProviderNamespace>
<Type>Caching</Type>
<Name>xxx</Name>
<SchemaVersion>1.0</SchemaVersion>
<ETag>xxx</ETag>
<State>Started</State>
<SubState>Active</SubState>
<UsageMeters />
<IntrinsicSettings>
<CacheServiceInput xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkuType>Basic</SkuType>
<Location>North Europe</Location>
<SkuCount>1</SkuCount>
<ServiceVersion>1.3.0</ServiceVersion>
<ObjectSizeInBytes>1024</ObjectSizeInBytes>
<NamedCaches>
<NamedCache>
<CacheName>default</CacheName><NotificationsEnabled>false</NotificationsEnabled>
<HighAvailabilityEnabled>false</HighAvailabilityEnabled>
<EvictionPolicy>LeastRecentlyUsed</EvictionPolicy>
<ExpirationSettings>
<TimeToLiveInMinutes>10</TimeToLiveInMinutes>
<Type>Absolute</Type>
</ExpirationSettings>
</NamedCache>
</NamedCaches>
</CacheServiceInput>
</IntrinsicSettings>
<OutputItems>
<OutputItem>
<Key>CreationDate</Key>
<Value>9/30/2014 9:46:42 AM +00:00</Value>
</OutputItem>
</OutputItems>
<OperationStatus>
<Type>Create</Type>
<Result>Succeeded</Result>
</OperationStatus>
<Label />
</Resource>
Object B (xmldocument) looks like this:
<Resource>
<IntrinsicSettings>
<CacheServiceInput xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SkuType>Basic</SkuType>
<Location>North Europe</Location>
<SkuCount>1</SkuCount>
<ServiceVersion>1.3.0</ServiceVersion>
<ObjectSizeInBytes>134217728</ObjectSizeInBytes>
<NamedCaches>
<NamedCache>
<CacheName>default</CacheName>
<NotificationsEnabled>True</NotificationsEnabled>
<HighAvailabilityEnabled>True</HighAvailabilityEnabled>
<EvictionPolicy>True</EvictionPolicy><ExpirationSettings>
<TimeToLiveInMinutes>10</TimeToLiveInMinutes>
<Type>Absolute</Type>
</ExpirationSettings>
</NamedCache>
</NamedCaches>
</CacheServiceInput>
</IntrinsicSettings>
</Resource>