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 8029377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:25:16+00:00 2026-06-05T00:25:16+00:00

Using the following I always get an invalid child element error. I am new

  • 0

Using the following I always get an invalid child element error. I am new to XML and I have been looking around the net to try and figure this out but have had no luck. I have another XSD that is verifying XML submitted to my application and it works wonderfully but it is using attributes instead of elements. Can’t get this to work using the elements in the XSD to validate XML being submitted through a 3rd party application that I have no control over.

XSD

<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"     xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="SCCAParticipationList">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Entry">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Address" type="xs:string" minOccurs="0" />
              <xs:element name="CarModel" type="xs:string" minOccurs="0" />
              <xs:element name="CarNo" type="xs:string" minOccurs="0" />
              <xs:element name="TotalTm" type="xs:string" minOccurs="0" />
              <xs:element name="BestTm" type="xs:string" minOccurs="0" />
              <xs:element name="Region" type="xs:string" minOccurs="0" />
              <xs:element name="MemberNo" type="xs:string" minOccurs="1" />
              <xs:element name="FirstName" type="xs:string" minOccurs="1" />
              <xs:element name="LastName" type="xs:string" minOccurs="1" />
              <xs:element name="Class" type="xs:string" minOccurs="1" />
              <xs:element name="Pos" type="xs:string" minOccurs="1" />
              <xs:element name="UniqueID" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


XML

<?xml version="1.0"?>
<SCCAParticipationList>
  <Entry>
    <MemberNo>3333333</MemberNo>
    <FirstName>Test</FirstName>
    <LastName>Person</LastName>
    <Class>stt</Class>
    <Pos>13</Pos>
    <CarModel>Mazda Miata</CarModel>
    <Address>123 Test Dr ,The Woodlands TX,55555,US</Address>
  </Entry>
  <Entry>
    <MemberNo>2222222</MemberNo>
    <FirstName>John</FirstName>
    <LastName>Doe</LastName>
    <Class>sio</Class>
    <Pos>3T</Pos>
    <CarModel>Subaru Impreza</CarModel>
    <Address>111 Test Circle ,Austin TX,77777,US</Address>
  </Entry>
</SCCAParticipationList>

C#

protected Boolean VerifyXmlwElements(string strSchemaPath, string strXml) { try {
byte[] byteArray = Encoding.ASCII.GetBytes(strXml); MemoryStream stream = new MemoryStream(byteArray); XmlTextReader xmlr = new XmlTextReader(stream); XmlValidatingReader xmlvread = new XmlValidatingReader(xmlr); xmlvread.Schemas.Add(null, strSchemaPath);

            xmlvread.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);

            while (xmlvread.Read()) { }

            xmlvread.Close();

            if (intErrCount > 0)
            {
                intErrCount--;
                throw new Exception(strErrMessage);
            }
            strErrMessage = "XML validation succeeded!\r\n";
            return true;
        }
        catch (Exception ex)
        {
            intErrCount++;
            strErrMessage = "Invalid XML - " + ex.Message + intErrCount.ToString() + " Error(s)\r\n";
            return false;
        }
    }

    private void ValidationCallBack(Object sender, ValidationEventArgs args)
    {
        if (args.Message.ToLower().Contains("attribute is not declared"))
        {
            return;
        }
        intErrCount++;
        return;
    }

  • 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-06-05T00:25:18+00:00Added an answer on June 5, 2026 at 12:25 am

    At least one problem is that you are ordering your Entry child elements incorrectly. Elements defined in a sequence tag must appear in the corresponding XML doc(s) in the same order.

    After validating your sample XML against your schema this was the only issue I saw.

    EDIT:

    If you have no control over the input file’s element order & it is not consistent & each child element of Entry can only appear a maximum of once per Entry, you may want to use the all element instead of sequence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following PHP code for trigger creation but always get error, please
I'm querying Wikipedia using the following code, but I always get an error (403
I'm using chrome devtools network API and the following code but always the alert
I am trying to learn a dataset using Svmlight. I always see the following
Using following code I try to get updated list of checkbuttons' corresponding text values,
I have built an enumeration in javascript using the following syntax: MyEnum = {
I'm using TouchXML to parse an XML-stream the following way: CXMLDocument *parser = [[CXMLDocument
I just try to post data to google by using the following code,but always
I'm working on an ASP.NET MVC app (using MVC3 RC2). Say I have 2
Problem Encountered At runtime, I always get the following NHibernate.MappingException : Could not compile

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.