Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: use section of XML as source/destination of XmlSerializer?

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 3/12/2009 6:37:00 PM
Craig Buchanan wrote:
> I have an Xml file that I use as a database of information about a 
> manufactures products.  It has the format:
> 
> <Manufacturer>
>     <Products>
>         <Product id="1" name="product a" price="1.00" />
>         ...
>     </Products>
>     <Suppliers>
>         <Supplier id="1" name="supplier x" />
>         ...
>     </Suppliers>
> </Manufacturer>
> 
> I would like to be able to use the Suppliers node as the source for the 
> XmlSerializer's Deserialize and Serialize methods.  I figure that I can load 
> an XmlDocument, then select the Suppliers node using an Xpath query 
> (//Supplers).  The question is how to send this to the XmlSerialier. 

Use an XmlNodeReader over the Suppliers XmlElement node e.g.
   Dim doc As New XmlDocument()
   doc.Load("file.xml")
   Dim suppliers as XmlNode = 
doc.SelectSingleNode("/Manufacturer/Suppliers")
   Dim reader As XmlReader = New XmlNodeReader(suppliers)
   ' now pass reader to Deserialze method of an XmlSerializer




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent