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
2079 Views

Similar Articles

[PageSpeed] 48

Reply:

Similar Artilces:

Requesting help to generate progress reports in Excel ...
Hi, I am a newbie to Excel and think I have a simple request but do not know how to get started. I would like to request help in generating progress reports for team mates on my "in house league" 8-ball pool team. I have been keeping a tally for the past 9 weeks of each persons wins and losses. I want a pie chart to illustrate their contribution to the team for the past 9 weeks. For example, I would like to see a percentage based on the total number of wins for each person. This percentage is displayed as percent/piece of the pie. Next, I would like to show a bar graph or line cha...

Creating XML element from XPath
Hi, Is it possible to automatically create an XML element given an XPath query? For example I have the following XML doc: <topic> <title>Hi this is the title</title> <description>This is a simple desc</description> </topic> Now say I have an XPath query '/topic/age' which will return a null node if I run it against the above XML doc. Now is there an easy way to automatically create the age node if it doesn't exist? Or do I need to do manual parsing and create the node manually? For the above example probably you'll think that ...

XSDObjectGen and generating multiple .cs files for multiple schema
I'm looking for a good tool to generate C# classes (from XSD-schemas) to (de-)serialize XML corresponding to those schemas. XSDObjectGen almost meets these requirements -- only, I need to generate a ..cs file for each common .xsd file that is included (xsd:include) -- there are a lot schemas which include several common .xsd files (full schema at http://www.witsml.org/schemas/WITSML120_2003-01-30.zip). The "/s" switch would have beein ideal for this, only it still generates only one .cs file -- maybe this is only for "imported" (as opposed to "included&quo...

New to xml
I'm trying to write my xsl to display an unordered list fromt the xml file where location is equal to top: <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="~/index.aspx" title="Home" location="top"> <siteMapNode url="~/about_us/index.aspx" title="About Us" location="top" > <siteMapNode url="~/about_us/mediaroom.aspx" title="Media Room" /> <siteMapNode url="~/about_us/awards.aspx" title="Awards" /> <siteMapNo...

intermittent issues with lowercase 't' 'h' 'c' in outlook.
The above letters will periodically cease to function in outlook but they continue to work in notepad. Lower case only is affected the uppercase works fine. ...

controlling spam with MSExchange.UceContentFilter.xml
Hi I need to know if there is a way of using a wild card word inconjunction with the MSExchange.UceContentFilter.xml. I will try to explain, recently our ISP who provide our first line spam filtering changed their methods of controlling spam and since this change we are getting alot more spam into our exchange systems. They delete obvious spam but the ones they are a little unsure about they now send it out and adjust the subject to include the word spam I now this sounds daft but just go along with it. So we are getting alot of spam with the different subjects all prefixed with {s...

Parse XML into Collection
I'm a newbie so please bear with me... I'm looking to parse XML into a Collection so that I can pass that collection around to functions to extract data from it easily. I'm hoping there is code already to parse std XML files into a Collection? All I've found is code where the XML structure is already known... I need to code to work no matter what the structure... it would "figure out" what nodes are parents/children and such then place them into a Collection appropriately. Any help is appreciated! An XmlDocument already defines a hierarchy of collections when it p...

DataSet and xml data without schema
Hi, How can I read data into an DataSet from an xml file that doesn't contain any schema references. The dataset is wysiwyg-created in VisualStudio. I've already tried the ...DataSet.ReadXml() method but that doesn't fill my dataset with the data from the file and also doesn't raise any errors. How can I convince the ...DataSet to read data from the unschematized xml-file? Erik ...

How do I write a response to a request from an xml data island?
I need to know the code I must write to respond xml to a data island as a result from a src request from the data island. Thanks so much Assuming the data island has a src attribute like: "getXML.asp", this ASP page would do it: <%@ language="JScript"%> <% var xmlDoc = new ActiveXObject("MSXML2.DomDocument"); xmlDoc.loadXML("<root>Some XML</root>"); Response.ContentType="text/xml"; xmlDoc.save(Response); %> Regards, Mike Sharp "Nicole Schenk" wrote: > I need to know the code I must write to respond x...

How to remove invalid e-mail generation rules?
I have a client which I just migrated Exchange 5.5 to Exchange 2003. All of the site addressing generation rules got transferred over from 5.5 into 2003 under recipient policies. There is an invalid entry in there that's causing the RUS service to stall. I would like to know how to remove this entry because the remove button is greyed out?? It seems that the remove button is only available if I custom create a new one. what's more perplexing is the fact that if I try to uncheck the entry then click ok, I get an error of "The specified directory service attribute or val...

Can not Load XML
Hi I am trying to load the XML document from a file like XmlDocument requestDoc = new XmlDocument(); requestDoc.Load( strFileName ); I am getting Error '&#9792;', hexadecimal value 0x0C, is an invalid character. Line 1940, position 1. I can load the same file using IE 6.0 with out any errors I am using Visual Studio .Net 1.1(2003) Any Clues ???? Thanks Kiran Kiran, 0x0C is not a legal character in any XML document (regardless if IE does display it). The spec explicitly spells out which characters may occur in a legal document [0]. You can find more information on thi...

Same class file for Win and Web
Hi I've a very simple class file with a number of static methods that I need to call from both a Windows app and a Web app. I dont want to build seperate dll's for these projects. The code should just be a part each project. I've tried in studio to add the .cs file to each project but instead of a reference to the same file the .cs file is copied to each project directory. Any help would be appreciated,- thanks. Peter Hello, > I dont want to build seperate dll's for these projects. The code should > just be a part each project. I've tri...

How to generate a report from multiple lists in Excel 2003?
I have a workbook that I am trying to use as an accessory order form for a wireless phone company. The workbook is comprised as multiple worksheets, one for each manufacturer. There is a column that denotes the quantity of each item ordered. I would like to generate an order summary at the end of the workbook that is easily printable for our wharehouse staff to fill orders. If anyone has any suggestions, they would be greatly appreciated, as I have been racking my brain over this for about a week. -Thank You ...

XML newbie: How to add/replace an attribute
Hi all, Whenever I need to deal with XML I kind of stumble around in the XML namespace until I find the class that seems to do what I'm trying to do. This time around, I've been trying to find a reasonably straightforward way to do something that should be very simple, and I've gotten to the point where I need to ask for help. I have a bunch of files that contain XML looks like this: <?xml version="1.0" encoding="utf-8"?> <manifest version="1" exceptions="*.doc"> <file>.\abc.txt</file> <file>.\def.txt&...

How to create xml elements with special chars
Hi, newbie that i am in .Net, i'm trying to add "D/T" as a new element in C# : XmlElement elemAttr = (XmlElement)m_xmlDoc.AppendChild(m_xmlDoc.CreateElement("D/T" ) ); but the framework throws an XmlException ... how do i overcome this ? do i have to parse the string for special chars myself ? please advise, thanks , nim_co. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! I don't think that you can. The XML standard limits the characters you can use (http://www.w3.org/TR/xml11/#dt-elem...

random number generation
how would I generate a random number from a list of given numbers i excel or better yet in vba, sy a I have a list of 1,2,3,4,5 and I wil like it randomly pick a number thnank -- nyn0 ----------------------------------------------------------------------- nyn04's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1265 View this thread: http://www.excelforum.com/showthread.php?threadid=26231 Hi! You could use =INT(RAND()*5)+1 or, if your version of Excel supports it, =RANDBETWEEN(1,5) Al -- Alf -------------------------------------------------------------------...

how to find nodes at xml file without complete load the xml file
how to find nodes at xml file without complete load the xml file since the file is very big!! joe wrote: > how to find nodes at xml file without complete load the xml file > since the file is very big!! You can read through the XML document with an Xml(Text)Reader, that is forward only pull parsing where your code only pulls in the current node. The documentation is here <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlTextReaderClassTopic.asp> for .NET 1.x and here <http://msdn2.microsoft.com/en-us/library/system.xml.xmlreader(...

Object to use for sending URL / retrieving XML
How do I get XML results from a URL into a set of variables (or controls on a form, or anywhere else I can use them within Access)? I need to build an interface to the Washington State tax code URL interface as a small part of a much larger application that has been running for several years. Their site accepts address-related arguments as part of the URL, then returns XML results. Here is the URL, using their example address (probably their office), so there is nothing confidential here: http://dor.wa.gov/AddressRates.aspx?output=xml&addr=6500 Linderson way&city=&am...

SSL in a C++ web services client
I'm trying to add SSL support to my web service client. It's written in VC++ 7.1 (Visual Studio .NET 2003), but it's NOT managed code. I've created the web service, and configured my server with a certificate, and tested it with IE, and it works fine. When I add a reference to the web service into my C++ client application, it will work unsecured, but not secured (using SSL). Apparently, the ATL classes don't have support for SSL sockets. Is this true? If so, what's the best way to achieve secure access to my web service from a C++ application? Thank you! ...

XMLDocument <- Synchronization Trasformation Schema -> XMLDocument ?
I'm new to .NET XML classes, so here my dilemma I really like the XMLDataDocument concept of synchronizing automatically XMLDocument and DataSet with a common schema. Can I automatically syncronize 2 XMLDocument with Synchronization Trasformation Schema in the middle? Here my plan I'm going to write an application which the core data model is based on XMLDataDocument with my own schema. The application frontend will edit the XMLDataDocument core. The application will have to edit files with a well known XML document schema similar to my core. I can easily create an XSLT to tranform t...

Converting dataset xml into adodb.recordset???
Hi, I have a need to conver the xml produced by a .net dataset (with a single table) into an adodb.recordset. The adodb.recordset doesn't understand the xml that the dataset.GetXml method produces. Can someone point me in the right direction? Thanks ... Ed Hi, see the code download for Dino Esposito's "Applied XML Programming for Microsoft .NET" http://www.microsoft.com/MSPress/books/6235.asp . In chapter 4 there is written as an example an XmlRecordsetWriter class (custom XML writer) which is capable to write ADO recordset compliant XML. It has WriteRecordset meth...

mspub.exe generated errors
I have Publisher 2000 and attempted to open several existing files that I was able to open before and now all the sudden cannot open. When I try to open get error "Mspub.exe has generated errors and will be closed by windows. Then Publisher closes. I spent all day dowloading and installing every update and patch available and still have the same problem. Any clues? HI there...Yes, it was the printer driver. I just got a new one from HP.com and reinstalled the printer. All workes well now!!! >-----Original Message----- >I have Publisher 2000 and attempted to open seve...

extracting a XML segment (element)
Hello, I need to extract an element from a xml document something like this <myXml> <Header> <Name/> <LastName/> <Age/> </Head> <Body> <Properties> <Address/> <Location/> <Country> </Properties> </Body> </myXml> I need to extract from my Stream the <Properties> element (and sub elements) located inside the Body element. How can I do that? Thanks a lot again! AA I forgot to mention that the element <P...

MSDN like documentation for Xml-files?
I would like to be able to generate documentation for a custom configuration file (xml) to enable future support engineers to understand applicable values to the various elements inside the configuration file. (see below for sample). Does any program exist (like NDoc) that is able to generate MSDN like documentation? <!-- CONFIGURATION SECTION --> <configurationSection> <caching> <!-- Should caching be used by the Configuration system ? Using caching greatly improves performance Values: "false" : Do not use "true" : Do use ...

What is the Best XML API for .NET 3.5?
I’m starting a new project which will dynamically generate (user will have to pick and choose data, then generate the XML dynamically) RDLC for Reporting. My approach was to use LINQ to XML for the API. My question is what is the best API to use? Performance is no concern, most critical factor is that the code be easy to maintain easy to dynamically generate the mark-up for the RDLC. Note: We are all ready using LINQ to XML in the main application. This is for the reprinting module of the application. -- Alexander L. Wykel AW Software Works Alexander Wykel wrote: > I’m start...