We help IT Professionals succeed at work.

XML Schema Same Name Element In Child and Parent

TSQLGuy30
TSQLGuy30 asked
on
2,820 Views
Last Modified: 2012-02-28
Lets assume I have the following XML:

<People>
    <DateCreate>1/2/2012</DateCreate>
    <Attributes>
        <Eyes>
            <Color>Blue</Color>
            <DateCreate>1/7/2012</DateCreate>
        </Eyes>
        <Arms>
            <Number>2</Number>
            <DateCreate>1/9/2012</DateCreate>
        </Arms>
    </Attributes>
</People>

If I use the following schema document:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="People">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="DateCreate" type="xs:dateTime" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

I'm getting an error when trying to load this in SSIS saying the following...

[XML Source [1]] Error: The component "XML Source" (1) was unable to process the XML data. The Xml source document contains multiple "DateCreate" elements and maxOccurs=1 was specified in the Xml schema.

I only want to pull in the DateCreate field in the People Node Level, Not in the Attribute Node level but it's trying to pull both in and says it can't do that.

Any Ideas on a fix?

Thanks All.
Comment
Watch Question

Kevin CrossChief Technology Officer
CERTIFIED EXPERT
Most Valuable Expert 2011

Commented:
HI. Just to clarify, you definitely only want the first DateCreate---the others should be ignored?
Chief Technology Officer
CERTIFIED EXPERT
Most Valuable Expert 2011
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.