Object Access to XSD created Class Confusing

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


0
clint9554 (2)
10/30/2003 11:39:16 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
609 Views

Similar Articles

[PageSpeed] 58

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



"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
>
>


0
clint9554 (2)
11/1/2003 12:42:56 AM
Reply:

Similar Artilces:

creating a pointer to a imbeded struct causes C2065
I want to create a pointer of a sub struct because there will be more than one of them in a message. However I get C2065 error. I found the error explaination on Microsoft.com however I don't see how it applies to me. Here is a simple idea of what I am doing. char szBuffer[100]; typedef struct T_Smoo { struct { int a; }H; struct { int b; int c; int d; }D; } Smoo; Smoo *pSmoo = (Smoo*) szBuffer; pSmoo->H.a = 1; pSmoo->D.b = 2; pSmoo->D.c = 3; pSmoo->D.d = 4; int offset = sizeof(pSmoo->H); Smoo::D *p = (&Smoo::D) &szBuffer[offset]; p->D....

CRM data access from external website
Hi All, I have a fully working CRM 3.0 solution on a dedicated server on my internal network. This server is also running SQL 2005 I have an externally hosted website on a Windows 2003 Server, located on the internet. I would like to be able to let some of my customers access to certain parts of my CRM solution, so that they can see the status of an order. I have developed a website on the external server that uses ASP.NET linked to my Internal SQL server and allows ASP registered users access to certain pages. On these pages I would like to use a table that shows the information that...

Objects duplicated
If a workbook consists of Objects: Sheet1, Sheet2, This Workbook.... What would cause Excel to duplicate these objects in the same workbook. Somehow, I now have to sets of objects in the same workbook that are exactly the same. ...

How to circumvent Access Denied?
We have a small home network with, at present, 4 Win XP computers and 1 Vista computer (although the Vista machine can be ignored for this query). I've had to do quite a bit of rearranging of folders/files recently, and I'm getting increasingly frustrated with Microsoft's insistence on denying access to some Documents and Settings subfolders and some Windows subfolders. Each computer has one user only and that user is the Owner. What can be done to provide EACH user with full access to ALL folders and files on ALL computers, using My Computer or Windows Explorer ...

Access 2007 Install Broke Access 2000 Runtime
I have an old Polaroid ID Cardmaker program that uses an Access 2000 Runtime to work. After installing Office 2007 Pro Plus I found that the cardmaker program would no longer work. The error is 2501 The OpenForm operation was cancelled. If I try to open the mdb file the error is "You do not have the necessary permissions to use the ........MDB object." If I use the Polaroid installation CD and reinstall the Access 2000 runtime the application will work but I can no longer open Access 2007 without it going through a reconfiguration. Once that happens the cardmaker app won't...

xsd.exe
Is xsd.exe an managed assembly? Can I use it on a machine that does not have the .NET Framework? I want to use it for its ability to take .dtd's and convert them to .xsd's. Thanks. Yes, it's managed. "Scott M." <s-mar@nospam.nospam> wrote in message news:OY$eLhiiFHA.1464@TK2MSFTNGP14.phx.gbl... > Is xsd.exe an managed assembly? Can I use it on a machine that does not > have the .NET Framework? I want to use it for its ability to take .dtd's > and convert them to .xsd's. > > Thanks. > ...

RegSetKeySecurity
I know how to use RegSetKeySecurity, to change a registry keys access to read only but is there a way to change to read only, where only I can change it back to read/write? Kinda like a password, you can read, but you can only write if you have correct "password" (note: I can't encryt the key, which it sounds like what I'm asking, it's not) Is there a way to use AllocateAndInitializeSid to do this? It has 8 slots for sub authorities....is there a way to just authorize access with sub authorities so that only if you use same ones again to change access right, can ...

How to Create Dynamic Range in Formula
I have a formula using a vlookup command. I want the range of the looku table within my formula to change based on the date I enter in separate cell. For example, If the date I enter into a separatecell matches the dat that is the heading for my first column of my array, that first colum would be the start of the range in the vlookup formula. For example, i I type 6/6/04, and my column heading matches that date, then I want th vlookup array to use the first column in its formula, which is =VLOOKUP(A5,SongSelect!M$2:$AM$90,27,FALSE) . If, however, I ente 6/13/04, ibecause 6/13/04 is the hea...

cannot shift objects off sheet, but also cannot find objects
Trying to hide columns gives error "cannot shift objects off sheet." Try as I might, I cannot find any objects in or near the offending columns; indeed, there are no objects on the entire sheet. I went to Tools>Options>View>Objects and selected "Show All," but still nothing appears. An easier way to see if there are any objects on a sheet is through F5-Special. Cell comments are objects too. Do you have any of them? -- Jim Rech Excel MVP "danielo" <anonymous@discussions.microsoft.com> wrote in message news:0cff01c47b0d$f5a72620$a601280...

converting microsoft works database to and access database
is there a way to convert an microsoft works database to an access database? Not completely. You can export the data to some format that Access can recognize (such as .DBF or .CSV) and then import it into Access, but you can't convert anything else. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele "Amanda" <acoldiron@ashe.k12.nc.us> wrote in message news:021e01c35ab6$62579300$a401280a@phx.gbl... > is there a way to convert an microsoft works database to > an access database? ...

How to record which objects a user clicks on
Hi, New to the forums here. I would like to know how to track which objects a user clicks during a powerpoint presentation. I realize this will probably require a macro and that is where I need help. I'm fairly tech savvy, but I don't know how to program in VB. Whenever there is a mouseclick on an object in the slideshow, I would like two things to happen: 1) Advance to a particular slide (which I see can be set easily in the program) 2) Write data, to a separate file (it can be a text file), that reports which object was clicked. This would happen in the background so t...

Problem With Opening Embedded Object After Turning On "Track Chang
In order to use the routing function, I'm using company forms created in excel. On another tab, I've embedded "as icon objects" any supporting material created in Word. This works great, as recipients can double-click these icon objects and launch the documents in Word to view them. The problem occurs when I decided to add "Track Changes" to the files I am routing. When this is done, the icon objects still appear but can no longer be double-clicked. The online documentation in excel indicateds that you can't insert any embedded objects after "T...

How do I group objects and Word Art in Publisher?
I am creating a button and have our company logo along with a slogan that I put in Word Art. I would like to group these two items together so it will be easier to move around as one object. I have tried using the "select object" tool and it will not let me group them. It just moves my objects around and not as a group. I don't quite understand. Do you have a border around your page? If so send it to the back and try selecting your logo and WordArt again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Fal...

Turn off object theme colors
I have a presentation with a number of objects (mainly simple shapes like circles and squares) that have powerpoint theme colors. I now want to copy and paste them into another Powerpoint that has a different theme. I of course don't want the colors to change. Other than going into each object and changing the color into a customized color, is there any way I can get these objects in using their original color - not tied to the theme? Hi When you paste the objects into the other presentation you'll get a little clipboard in the bottom right hand corner - click on ...

Macro to create outlook appointment
I have posted a number of questions recently based around this subject. I have nearly finished but need a couple more things before it is perfect. My code is as follows:- Macro 1:- Sub RunIf() For Each c In Range("C3:F14") If c.Value = "A/L" Then If c.Offset(0, 1).Value = "done" Then 'skip it' Else 'do it' Call Add_Appointment c.Offset(0, 1).Value = "done" Call Add_Appointment End If End If Next End Sub Macro 2 - Sub Add_Appointment() Dim myOlapp As Object Dim m...

Converting back to Access 2003
I want to convert a Access 2007 database to Access 2003 file type (mdb). I get an error message saying I need permission to do this. Where do I change permissions? Ed ...

Vista & Access 97
Hello All I Have aproplem that in a certain PC which works under windows vista the access 97 is corrupted when you run any access applcation, the same application is worked truly in other windows systems (xp,98,...) can any one help us thanks hi, Developer wrote: > I Have aproplem that in a certain PC which works under windows vista the > access 97 is corrupted when you run any access applcation, the same > application is worked truly in other windows systems (xp,98,...) can any one > help us Where is your .mdb located? Using offline-folders is a known problem under so...

how to create escalation form
How do I create escalation form. Abe wrote: > How do I create escalation form. Since you're the only one here who knows what you're escalating, to whom, in what way and for what reason, you are the only one who can tell what the form should look like. In general, you should create a Word template: http://www.word.mvps.org/FAQs/Customization/CreateATemplatePart1.htm If the form needs to have text that doesn't change, and places to enter text that does change, then you should create it as a form template: http://www.word.mvps.org/FAQs/TblsFldsFms/LinesInForms.h...

xml serialization of a class and adding qualified namespace #3
I am successfully serializing to XML from a class like this: private static void CreateXML() { testClass c = new testClass(); c.stringElement = "data1"; c.stringElement2 = "data2"; subClassDataType s = new subClassDataType(); s.subThingElement1 = "data3"; s.subThingElement2 = "data4"; c.subThing = s; XmlSerializer mySerializer = new XmlSerializer(typeof(testClass)); System.IO.StreamWriter myWriter = new System.IO.StreamWriter("test3.xml"); mySerializer.Serialize(myWriter, c); } My class definitions are as follows: [Serializable] [System.X...

I created two documents and now I want to put them into one docum.
I'm trying to put two publications together. I created them seperately and now want to merge them together. I thought it would be as easy as power point and the cut and paste mode. What am I doing wrong? Copy and paste. (Use Select all on each page and make your life simple.) -- JoAnn Paules MVP Microsoft [Publisher] "Bethany Read" <Bethany Read@discussions.microsoft.com> wrote in message news:71C567BE-2704-4B40-A402-4BABC580EF05@microsoft.com... > I'm trying to put two publications together. I created them seperately > and > now want to merge the...

MS Access Table Design Look Up???
I am trying to design a budget database and I want to have consistent categories and expense. I have a table with Category and Expense It looks something like this: Category Expense Overhead Electrcity Overhead Internet Employee Salary Employee Commision I want to creat another table where the entires will be made but want to force these categories. I can get one colum to appear in the table Example Internet but I can't see in the table what category it rolls up to, I see it when I choose the expense but not after. Is there a way to populate this ...

Enter to create a new line within a cell in Excel 2000
Excel 2000: Multiple lines of text within one cell. ex: date: text... date: text... I need to distinguish the dates within oen cell so each needs to be on its own line. date: text... date: text... rather than all running together. I've tried every keyboard shortcut I could find and nothing worked. Hi ALT+ENTER -- Regards Frank Kabel Frankfurt, Germany "Gem" <Gem@discussions.microsoft.com> schrieb im Newsbeitrag news:D06AAA81-BEB1-4312-BEDF-2ABCD39491A3@microsoft.com... > Excel 2000: Multiple lines of text within one cell. ex: date: text... > date: text...

Insert Object File path when attaching OLE Objects
When attaching a note and click on the paper clip, I go to Edit Insert New Object to attach a word document or an excel file. When I select 'Insert New Object' the Insert Object screen opens and I select the Create from File option. The path showing there is the path where GP is installed, in my case - c:\Program Files\Microsoft Dynamics\GP\. Is there a way I can change this default path? Maria, I am afraid this path defaults from the location of your DEX.INI file, which in the case of GP 9, can be found typically under the GP root folder, in the case of GP 10, under the GP...

WTL objects dependent on what runtime objects?
If I make and distribute a WTL program, what DLL's (if any) must also be present? I mean, if I make an MFC application, I assume that my installation program is also going to need to make sure that MFC42.dll and maybe a couple of other DLL's is on the target machine and up to date. What is a WTL program dependent upon? *********** Richard Lewis Haggard "Richard Lewis Haggard" <HaggardAtWorldDotStdDotCom> wrote in message news:OBcsU13uDHA.640@tk2msftngp13.phx.gbl... > If I make and distribute a WTL program, what DLL's (if any) must also be > present? I mean...

Access 97 to XP conversion
I have a large Access 97 App that has been running in Windows 2000. I'm switching to XP and I am getting a lot of issues running Access 97. My VBA functions will any work if I prepend them with VBA and some of my combo boxes are no longer working correctly (must use mouse to scroll and choose, just cannot type letters). I'm sure I'll run into more issues later on. Does anybody have a suggestion as to the problems I'm experiencing (and I'm using a SQL Server 7.0 backend for the data)? Thanks, ts Your references are probably messed up. This can be caused by differences...