IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

xsd metadata Options · View
Jim Carlson
Posted: Wednesday, August 5, 2009 7:40:14 PM
Rank: Newbie

Joined: 8/5/2009
Posts: 1
Location: New Jersey
Does anyone have any C# code example for accessing xsd metadata?
Rocco
Posted: Thursday, October 8, 2009 9:58:15 AM
Rank: Advanced Member

Joined: 5/16/2009
Posts: 82
Hi Jim,

You can generate C# code based on your xsd with XMLSpy. Then you have easy access to the schema metadata, as explained in this page:

https://www.altova.com/manual/XMLSpy/spyenterprise/using_the_generated_c_library2.htm

So if you want, for example, retrieve the MaxOccur and MinOccur values, then you can do this (based on the second example in the link above):

protected static void Example()
{
Library.Library2 doc = Library.Library2.LoadFromFile("Library.xml");
Library.LibraryType root = doc.Library3.First;
Library.BookType book = root.Book.First;
System.Console.WriteLine(root.Book.Info.MinOccurs);
System.Console.WriteLine(root.Book.Info.MaxOccurs);
}



Cheers

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.