troubleshooting Question

XML Schema Same Name Element In Child and Parent

Avatar of TSQLGuy30
TSQLGuy30 asked on
Microsoft SQL Server 2008
2 Comments1 Solution2863 ViewsLast Modified:
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.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros