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

Reorder XML Nodes based on schema content

$
0
0

I have a schema that I cannot control that specifies the xsd:sequence node. Example:

<xsd:schema>
   <xsd:element name="Something" type="Something_Type" /> 
   <xsd:complexType name="Something_Type">
      <xsd:sequence>
         <xsd:element ref="Item1"/>
         <xsd:element ref="Item2"/>
         <xsd:element ref="Item3"/>
      </xsd:sequence>
   </xsd:complexType>
</xsd:schema>

I also have a piece of xml coming out of another system like this:

<Something>
   <Item3>A</Item3>
   <Item1>B</Item1>
   <Item2>C</Item2>
</Something>

As you can see the elements are in the wrong order so the xml is not valid. Is there a way to progomatically re-order the nodes so they are in the correct order? This is obviously a very simple example and the real schema and file are very large. Thanks


Viewing all articles
Browse latest Browse all 935

Trending Articles