Actually, it was a bit of a newbie question. It turns out xsd.exe
schema-to-class transformations kind of fall apart in jagged array
situations (nested and unnested xml nodes beneath a parent) - which is what
most are. You'll note that most examples stick to simplistic nesting
scenareos when demonstrating xsd.exe to classes for xml serialization.
The trick was to clean up the class file created by xsd.exe and create the
proper public properties to actually represent the xml structure and schema.
Hopefully xsd will improve with age to be able to handle deeply nested xml.
The new "parent" class looks like:
<XmlTypeAttribute([Namespace]:="
http://tempuri.org/discovery_template.xsd"),
_
XmlRootAttribute("Discovery",
[Namespace]:="
http://tempuri.org/discovery_template.xsd",
IsNullable:=False)> _
Public Class Discovery
<XmlElementAttribute("ProjectInformation")> _
Public ProjectInformation As ProjectInformation
<XmlElementAttribute("ProspectInformation")> _
Public ProspectInformation As ProspectInformation
<XmlArrayAttribute("OurResources")> _
Public OurResources() As OurResource
<XmlArrayAttribute("Documents")> _
Public Documents() As Document
<XmlArrayAttribute("ProspectResources")> _
Public ProspectResources() As PR
End Class
....
It was worth the effort to figure it out because frankly I find using
serialization far superior in most cases to using xmldocument and
xmldatadocument to wire up a windows form.
32U
[quoted text, click to view] "32U" <clint@NO_SPAM_PLEASE32u.com> wrote in message
news:utoUs7znDHA.1632@TK2MSFTNGP10.phx.gbl...
> Maybe newbie question but I'm stumped after much search of google.
>
> Last week created class using xsd.exe against xsd file from well nested
xml
> that rendered in part:
>
> ... _
> Public Class MacroflowCatalog
> '<remarks/>
> <System.Xml.Serialization.XmlElementAttribute("MacroFlow")> _
> Public Items() As MacroflowCatalogMacroFlow
> End Class
> ...
>
> I was then able to reference MacroflowCatalog.Items(0).MacroFlow(0)...more
> depth from here, using Intellisense. In other words, everthing mapped
neatly
> into nested arrays from the xml pattern.
>
> This week I'm using same approach but different xml to xsd to class.vb.
> There are nodes that stand outside the nesting hierarchy. The output from
> xsd to class file is:
>
> ... _
> Public Class Discovery
> '<remarks/>
> <System.Xml.Serialization.XmlElementAttribute("ProjectInformation",
> GetType(DiscoveryProjectInformation)), _
> System.Xml.Serialization.XmlElementAttribute("ProspectInformation",
> GetType(DiscoveryProspectInformation)), _
> System.Xml.Serialization.XmlElementAttribute("OurResources",
> GetType(DiscoveryOurResourcesOR())), _
> System.Xml.Serialization.XmlElementAttribute("Documents",
> GetType(DiscoveryDocuments)), _
> System.Xml.Serialization.XmlElementAttribute("ProspectResources",
> GetType(DiscoveryProspectResourcesPR()))> _
> Public Items() As Object
> End Class
> ...
>
> I am having a hard time figuring out how to get at the object. I am not
sure
> how to deal with the Items() reference as Object type. Do I need to change
> the xml nesting in order to produce an object model? What do I need to
pass
> to Discovery.items()?
>
> Just need a pointer in the right direction.
>
> 32U eSolutions
>
>