![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - use section of XML as source/destination of XmlSerializer? >Thread Next - Re: use section of XML as source/destination of XmlSerializer? Re: use section of XML as source/destination of XmlSerializer?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/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
