XML Generation C# from helper class generated by XSD from a schema

I am working on creating XML from a very complex schema with multiple
complex types.  I've gotten through all the problems so far but this
one has me stymied.  It is probably simple to resolve.

The helper class is below - my code attempt is here.  At runtime I get
an exception also noted below.  The question - how to I use the helper
class to get the result also pasted below.

The result desired:

            <Identification>
               <NCPDPID>9900009</NCPDPID>
            </Identification>

The code attempt:

            rq.Pharmacy.Identification = new PharmacyIDType();
            rq.Pharmacy.Identification.Items[0] = "NCPDPID";
            ID.ItemsElementName[0] = ItemsChoiceType.NCPDPID;


Helper Class:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://
www.xxx.com/messaging")]
public partial class PharmacyIDType {

    private string[] itemsField;

    private ItemsChoiceType[] itemsElementNameField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("BINLocationNumber",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("DEANumber", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("FileID", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("HIN", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("MedicaidNumber",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("MedicareNumber",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("NAICCode", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("NCPDPID", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("NPI", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("PPONumber", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute("PayerID", typeof
(string))]
    [System.Xml.Serialization.XmlElementAttribute
("PriorAuthorization", typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("PromotionNumber",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("SecondaryCoverage",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute("SocialSecurity",
typeof(string))]
    [System.Xml.Serialization.XmlElementAttribute
("StateLicenseNumber", typeof(string))]
    [System.Xml.Serialization.XmlChoiceIdentifierAttribute
("ItemsElementName")]
    public string[] Items {
        get {
            return this.itemsField;
        }
        set {
            this.itemsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public ItemsChoiceType[] ItemsElementName {
        get {
            return this.itemsElementNameField;
        }
        set {
            this.itemsElementNameField = value;
        }
    }
}

// items choice type:

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://
www.surescripts.com/messaging", IncludeInSchema=false)]
public enum ItemsChoiceType {

    /// <remarks/>
    BINLocationNumber,

    /// <remarks/>
    DEANumber,

    /// <remarks/>
    FileID,

    /// <remarks/>
    HIN,

    /// <remarks/>
    MedicaidNumber,

    /// <remarks/>
    MedicareNumber,

    /// <remarks/>
    NAICCode,

    /// <remarks/>
    NCPDPID,

    /// <remarks/>
    NPI,

    /// <remarks/>
    PPONumber,

    /// <remarks/>
    PayerID,

    /// <remarks/>
    PriorAuthorization,

    /// <remarks/>
    PromotionNumber,

    /// <remarks/>
    SecondaryCoverage,

    /// <remarks/>
    SocialSecurity,

    /// <remarks/>
    StateLicenseNumber,
}

0
10/30/2009 4:21:37 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
2096 Views

Similar Articles

[PageSpeed] 33

Reply:

Similar Artilces:

XML schema validation #3
Hi, I have a XML file which I validate against a schema using the following: doc.Schemas.Add("", xsdSchema); doc.Validate(new System.Xml.Schema.ValidationEventHandler(ValidationErrorEvent)); This works fine, and I get the correct error when changing element names and structure. But when the XML to validate contains a different namespace than the one trying to validate I don't get an error, I can see why. So my question is how do I define the schema or my code to fail validation when a wrong NS is contained in the XML. Samples: <root><elements>value</elements>...

product key generator
I want to use Microsoft-style product keys for my product. Anyone know which algorithm could be used to create and validate the keys? Is there any free source code availabe? thanks DR DR wrote: > I want to use Microsoft-style product keys for my product. Anyone > know which algorithm could be used to create and validate the keys? > Is there any free source code availabe? Wouldn't that kinda defeat the purpose ? -- Sigurd http://utvikling.com "Sigurd Stenersen" <sigurds@utvikling.com> wrote in message news:u2nbaZQsEHA.1404@TK2MSFTNGP11.phx.gbl... > D...

split massive xml file
I have an xml file (sample below) that is massive. hundreds of megs maybe thousands. I need to split it up into multiple files so each file gets a copy of the header element and sub elements and 1 detail element. There will be 1 file created for each detail element. Any tips how to do this? Can I get away with not loading the whole file into memory at one time? sample: <header> </header> <details> <detail /> <detail /> <details /> "Jeremy" <nospam@please.com> wrote in message news:%23oCR4hcsHHA.1208@TK2MSFTNGP03.phx.gbl....

XML syntax coloring
Hi. I would like to ask If somebody don't have any small sample to coloring XML syntax, e.g. in RichTextBox. It can be in VB.NET or C#. I watched on SharpDevelop, but I could not understand that code, which is coloring text. Thanks. ...

Reading XML
I am reading the field names of Leads into a dataset - and only the first 13 or so show up. I import them to a string - then to a dataset. Do you think the string is the limiting factor? I am basically trying to mimic the Import Wizard for Leads and add a duplicate check function. If anyone knows where the code is for that wizard I would appreciate it as well!! THANKS! How are you getting the field names? Using SQL to get them would be much easier and considerably faster (the SDK is horrible slow compared to SQL calls, just don't use SQL to make changes, read only). I'm assumi...

Best in Class Visual Reports for Mgmt
Hi, I am looking for some examples of 'Best in Class' visual reports for hi-level management use. Specifically, reports that demonstrate the project status in both financials (ex: EVA) and overall progress. I know there are some of the standard MS Projects reports, but my manager is looking for any additional reports that have favorable reviews. Thanks so much for your help! Download the free 30 day trial version of DecisionEdge. There's a lot of sample reports there that are all validated by industry. "shasta1987" wrote: > Hi, > > I...

XSLT: dataset XML -> HTML
Hi Guys, I need a little help, I have XLM extracted from ADO.NET Dataset: <?xml version="1.0" ?> <NewDataSet> <xs:schema id="NewDataSet" ...> <xs:element name="NewDataSet" msdata:IsDataSet="true"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="my_table"> <xs:complexType> <xs:sequence> <xs:element name="fld1" msdata:Caption="Field 1" msprop:DataType...

ANN: XMLMax Virtual XML Editor Beta
Xponent LLC is pleased to announce round two beta testing of its XMLMax Virtual XML Editor. Beta testers who work with xml documents, preferably with files several megabytes to several gigabytes in size, are needed at this time. XMLMax is a validating xml editor written in C# that is W3C compliant, supports xpath 1.0 and is namespace aware. It provides xpath query and editing of any xml file, including ones too large to load into a DOM or other in-memory application. Xponent website: http://www.xponentsoftware.com ****** Key Features: ****** * Incremental parsing and loading allow editi...

performance of system.xml vs msxml4.0
I have an xsl file to generate xml in to an html file. The size of the xsl is 300kb and size of the xml is 47 kb (the size of xml is variable). I am using VB.net to convert the xml file into an html file. The vb.net module peforms following task: load the xml file in XMLDocument object ( I can't use XpathDocument object) load the xsl file in XSLTransform object perform the transformation. When I was using VB6 with Msxml 4.0 parser, I was getting good performance results. The transformation was completed in an average time of 40-50 milli second. When the same trasformation was perf...

Class reuse problem
Hi. Being relatively new to OOP programming, I've managed to 'get things working' but always struggled with the best way of doing it. Now I'm struggling with a problem that I hope you can help me with. Simply, I'm trying to write two app's - one for a Windows Desktop and the other for Windows Mobile. Both performing similar functions on different copies of the same data. I have 3 projects. Win desktop, Win Mobile and common classes. For the purpose of this post, I shall be referring to a common class called Person. Currently, the desktop data is held in an Access...

C-DLL-VBA-EXCEL strings
Hello, I'm trying to connect excel to a C dll library (call C dll from excel through the VBA). It works well for returning integer and double values (see simple example below), but I can't seem to get it to return strings. I am using MinGW gcc (so basically only C) to construct my dll, so I don't have access to BSTR and other cpp like objects/functions... Is there a way to make the C dll return strings to excel? Thanks DLL.c #ifdef BUILD_DLL #define EXPORT __declspec(dllexport) #else #define EXPORT __declspec(dllimport) #endif EXPORT int __stdcall add2(int num){ return num + 2; ...

adding a event handler in MFC application for c# event
Hello all, Im trying to call my .net c# library functions from my unmanaged vc++(dialog based MFC) application . From that application i want add the event handler for the event generated in c# dll so how to do that Here is my code.. #using <mscorlib.dll> #using "ircConnect.dll" //This is the c# dll reference __gc class GlobalObjects { #pragma push_macro("new") #undef new public: static ircConnect::IrcConnection *iIRC =new ircConnect::IrcConnection(); public: __event ircConnect::IrcConnection::MessageEventHandler* MessageIncome; #pragma pop_macro(...

ADAM Backup generating an Event 2089
I have two adam instances installed in a domain. The OS they are running on is Windows Server 2003 R2 SP2. I have been performing NT backups of the entire "C" drive where ADAM is installed as well as a system state backup of the machine. I am getting Event ID 2089 warning messages in the ADAM event logs that the partitions need to be backed up. I opened up a case with MS about this in February of 08 and they told me it was a bug with the VSS writer updating the dsasignature attribute. My question is if I continue to get these messages the user objects in ADAM will not t...

How to generate MS Word documents (CRM3.0)
�ste es un mensaje de varias partes en formato MIME. ------=_NextPart_000_001E_01C8A624.D4495BB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi: =20 We need Dynamics CRM generates MS Word documents merging CRM data and = static Word templates. As far as we know, there isn't a simple way to = have this functionality in place, so there are some third parties = selling such type of add-on. =20 Do you know any good product (and cheap) being capable to perform a mail = merge and generating Word documents? Note: Documents we need ...

Book for a windows/c++/mfc beginner...
Hi, I have previous coding experience, but not in the windows environment and not in C/C++. I have just got a copy of MS Visual C++ Express and want to learn how to code C++ for Windows. As I understand it I need to use MFC for the windows stuff, and without it Visual C++ would just be command prompt based? Is that correct? If so then I need a book that teaches me MFC and C++, preferably in the Visual C++ environment... Which is the best book/books for this? Thanks. anon418600J5 wrote: > Hi, > > I have previous coding experience, but not in the windows environment and...

Generate random sequence based on probability
I have a list of events and the probability that each will happen. Example: Event A 12% Event B 20% Event C 2% ...and so on. My list is about 20 entries long. What I want to do is to have Excel randomly determine what event will happen in what order, based on the percentage chance that it will happen. So I want 20 cells in another column with the results looking something like this: Event K Event B ...and so on. And be able to recalculate upon refresh. Thanks in advance!! Assuming the list is in A1:A20 - In cell C1 type: =INDEX($A$1:$A$20,MATCH(LARGE($B$1:$B$20,ROW()),$...

Datalist with an xml file
This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C6359F.293BB990 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How do I get all the name(s) listed in the datalist? <asp:DataList ID=3D"DataList1" runat=3D"server" = DataSourceID=3D"XmlDataSource1"> <ItemTemplate> <table> <tr> <td><%# XPath("Name")%></td> </tr> </table> </ItemTemplate> </asp:DataList> <asp:XmlDataSource ID=3D"XmlDataSource1&quo...

Why can I not XPath to this element in a schema
I've tried to find the simplest demonstration of my issue. I have source XML that looks like this (not a real XSD schema, but it doesn't matter at this point): (in var xmlStr:) <xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema">abab</xsd:element> Essentially, it's just an xml node w/ an xsd prefix, and the namespace defined right on the node. Then, some jibberish is the text of the node ("abab"). Using .NET, if I load this XML into an XmlDocument like this: XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlStr); doc.SelectSingleNode(&q...

How to parse an XML file
Hi. This should be a walk in the park for almost anyone... I'm a skilled win32 programmer, trying to learn asp.net 2.0 I've tried making a XML file parsing it to draw a GUI (web application) I have a small example: <?xml version="1.0" encoding="utf-8" ?> <Persons> <Person ID="ET40"> <FirstName>Bart-Jan</FirstName> <LastName>Brouwer</LastName> </Person> <Person ID="ET50"> <FirstName>Morten</FirstName> <LastName>Jacobsen</LastName> </Person> </Persons> I ...

C'mon MPVs
I already posted this once and got zero response as did another poster with the exact same issue. On a PC running Win2K Pro and Office XP, I set Outlook to use Word as the editor. Whenever Outlook is first started, it opens Word and displays a full screen window (with no blank document). I can close the window and everything appreas to work normally. My laptop has the same configuration but doesn't have this problem. I can't find anything different that would explain it. Any ideas? Sometimes we only know the answer because the same thing happened to us or because someone else h...

Error serializing derived Custom Collection Class
I am receiving an error stating that File or Assembly name <filname.dll>, or one of its dependencies, was not found In one assembly I have three abstract classes In another I have three derived classes from the abstract classes The 1st class contains the 2nd class The 2nd class is a custom collection for the 3rd class when I serialize the 1st class I am receiving the error. The classes look like the following: Abstract classes: using System; using System.Xml.Serialization; namespace AbstractClasses { public abstract class ContainerBase { private LocationsCollectionBase _loc...

Fetch XML to Query Expression
I'm trying to convert the following Fetch XML statement to a Query Expression to post using the RetrieveMultiple webservice: <fetch mapping="logical"> <entity name="role"> <attribute name="name" /> <link-entity name="systemuserroles" from="roleid" to="roleid"> <filter> <condition attribute="systemuserid" operator="eq-userid" /> </filter> </link-entity> </entity> </fetch> I haven't been able to find an documenta...

XML Source Menu Item disabled?? File version??
My XML Source Menu Item is disabled (aka greyed-out). Why? I have a workbook with multi-worksheets and I want to enable a conversion to XML, I'm trying to follow the documentation here, but it's poorly organized and more poorly written (IMHO).. I can't find anything which tells me why the menu item would be disabled. The version is Office 2003 Pro and (clearly) the capability is there, I can see the "XML Source" item. I did a quick test and if I make a brand new file, I have the XML Source option so that means means this is a file version issue?. I know this wo...

Syntax error with WinDBG command line -c ".cls;g"
I am using WinDBG 6.12.2.663 to debug a target (VMWare ware guest) over COM pipe. I intend to pass a command line that clears the screen and continues debugging. So, I pass -c ".cls;g" and I get the syntax error Processing initial command '.cls;g' 0: kd> .cls;g ^ Syntax error in '.cls;g' It works fine if pass just -c ".cls" WinDBG help states that "If you are starting a debugging client, this command must be intended for the debugging server. Client-specific commands, such as .lsrcpath, are not allowed. ". Is that wha t...

Help Editing an XML File
Greetings, This is my first post and I am hoping (praying) someone could help me. I am not a programmer, I just know enough to be dangerous. I have a custom application someone developed for me that generates an XML file to display web pages. Following is a very small portion of an example file: <QLabel>Position</QLabel><QText>Which one of the following best describes your primary job function?</QText><RotationValue>0</RotationValue> <LastOnPage>false</LastOnPage> I want to modify the XML file so that the web pages are displayed in Sp...