Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3936280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:55:41+00:00 2026-05-19T23:55:41+00:00

I have the following complex type in my XML schema: <xs:complexType name=Widget mixed=true> <xs:sequence>

  • 0

I have the following complex type in my XML schema:

<xs:complexType name="Widget" mixed="true">
    <xs:sequence>
        <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

The element in derived XML could contain string or could contained wellformed XML, hence the mixed attribute being true.

When I run this through the .NET XSD Tool I get the following generate code:

public partial class Widget{

    private System.Xml.XmlNode[] anyField;

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    [System.Xml.Serialization.XmlAnyElementAttribute()]
    public System.Xml.XmlNode[] Any {
        get {
            return this.anyField;
        }
        set {
            this.anyField = value;
        }
    }
}

The question I have is that I am not entirely sure how I should then use this. Ultimately I need to be able to set the value of widget to either:

<widget>Hello World!</widget>

or

<widget>
  <foo>Hello World</foo>
</widget>

Both of which validate agaisnt the schema

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:55:42+00:00Added an answer on May 19, 2026 at 11:55 pm

    For this:

    <widget>  
        <foo>Hello World</foo>
    </widget>
    

    Use this:

    XmlDocument dom = new XmlDocument();
    Widget xmlWidget = new Widget();
    xmlWidget.Any = new XmlNode[1];
    xmlWidget.Any[0] = dom.CreateNode(XmlNodeType.Element, "foo", dom.NamespaceURI);
    xmlWidget.Any[0].InnerText = "Hello World!";
    

    For this:

    <widget>Hello World!</widget>
    

    Use this:

    XmlDocument dom = new XmlDocument();
    XmlNode node = dom.CreateNode(XmlNodeType.Element, "foo", dom.NamespaceURI);
    node.InnerText = "Hello World";
    
    Widget w = new Widget();
    w.Any = new XmlNode[1];
    w.Any[0] = node.FirstChild; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following: <xs:schema> <xs:complexType name=NameType> <xs:sequence> <xs:element name=NamePrefix type=core:NamePrefixType minOccurs=0/> <xs:element name=FirstName
I have the following xsd snippet: <xs:complexType name=HighSchoolType> <xs:sequence> <xs:element name=OrganizationName type=core:OrganizationNameType/> <xs:group ref=core:OrganizationIDGroup
Say you have the following in a schema: <xsd:complexType name=shape/> <xsd:complexType name=circle> <xsd:complexContent> <xsd:extension
I have a schema fragment that looks like <xs:element name=dataValue> <xs:complexType> <xs:sequence> <xs:element name=value
Here is a extract from my XML schema: <xsd:complexType name=MyType> <xsd:sequence> <xsd:element name=Numbers> <xsd:complexType>
I have the following elements (excuse the syntax) :- <xs:complexType name=shop_T> <xs:element name=city type=xs:string
I have the following elements in my schema: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:complexType name=optimizeModelBase>
I have the following xml schema: <?xml version=1.0 encoding=utf-8?> <xsd:schema xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:xsd=http://www.w3.org/2001/XMLSchema attributeFormDefault=unqualified
I have an XML Schema that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=root> <xs:complexType>
I have the following XML: <customer> <name>John Paul</name> <cpf_cnpj>1376736333334</cpf_cnpj> </customer> The <cpf_cnpj> element must

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.