Deserialize xml to object.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bhu

    #1

    Deserialize xml to object.

    I have a xml which is like this.
    now if i remove the iu part from the xml then i am able to deserialize but i
    don't want to do it,
    any idea how to do it ?

    XML:
    <iu:InventoryUp dateBatch
    xmlns:iu="http://www.abc.com/schema/InventoryUpdate "
    xmlns:th="http://www.abc.com/schema/TransactionHead er"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
    <InventoryUpdat e>
    <TransactionHea der</TransactionHead er>
    </InventoryUpdate >
    </iu:InventoryUpd ateBatch>

    Code:
    public class InventoryUpdate Batch
    {
    [System.Xml.Seri alization.XmlEl ementAttribute( "InventoryUpdat e")]
    public InventoryUpdate[] InventoryUpdate type;
    }

    InventoryUpdate Batch invtype = new InventoryUpdate Batch();
    System.Xml.Seri alization.XmlSe rializer serializer = new
    System.Xml.Seri alization.XmlSe rializer(invtyp e.GetType());
    System.IO.Strea mReader w = new StreamReader(@" C:\b.xml");
    invtype = (InventoryUpdat eBatch)serializ er.Deserialize( w);

    thanks
    bhu



Working...