具有相同元素名称但属性值不同的XML的XSD架构

时间:2017-12-20 18:40:17

标签: c# xml xsd

我以前从未在XSD上工作过。今天我需要在数据库中验证1000万个XMLS。在通过不同的技术进行验证之后,我决定使用c#中的XSD和xml方法来验证xmls。我需要帮助为我的xml结构创建XSD。游戏场以不同的xmls重复任意一次。

<PlayAttributes>
  <PlayFields>
    <PlayField ID="XInfo.XInfo_QBAtPass" TS="">P</PlayField>
    <PlayField ID="XInfo.XInfo_Huddle" TS="">F</PlayField>
    <PlayField ID="XInfo.XInfo_DefScoreAfter" TS="">30</PlayField>
    <PlayField ID="Play.Offense.Off_Text_21" TS="2013-11-15 13:55:54">MWMUG</PlayField>
    <PlayField ID="Play.Shared.playResult" TS="2013-10-21 07:46:57">0</PlayField>
    <PlayField ID="Play.Migration.repTime" TS="2013-10-21 07:46:57">123</PlayField>
    <PlayField ID="Play.Migration.offensiveTeam" TS="2013-10-21 07:46:57">CAR</PlayField>
    <PlayField ID="Play.Offense.Off_Front" TS="2013-11-15 13:55:50">N42ELX</PlayField>
    <PlayField ID="XInfo.XInfo_LateralSeq" TS="">F</PlayField>
    <PlayField ID="Play.Offense.Off_Slot_Route" TS="2013-11-15 13:09:41">TREY</PlayField>
    <PlayField ID="Play.Offense.Off_Text_24" TS="2013-11-15 13:09:37">G FR</PlayField>
    <PlayField ID="XInfo.XInfo_EventCode" TS="">Incomplete Pass</PlayField>
    <PlayField ID="XInfo.XInfo_PlayersRushed" TS="">4</PlayField>
    <PlayField ID="XInfo.XInfo_YdGained" TS="">0</PlayField>
    <PlayField ID="XInfo.XInfo_Receiver" TS="">Quick, Brian (390159)</PlayField>
    <PlayField ID="XInfo.XInfo_Location" TS="">L</PlayField>
    <PlayField ID="Play.Shared.Field_2_Minute" TS="2013-11-15 13:08:07">2</PlayField>
    <PlayField ID="XInfo.XInfo_DriveStart" TS="">692</PlayField>
    <PlayField ID="Football.FrontTypeNew" TS="2013-11-15 13:55:48">E</PlayField>
    <PlayField ID="XInfo.XInfo_OffRole1" TS="">NO-No Data</PlayField>
    <PlayField ID="XInfo.XInfo_OffRole2" TS="">NO-No Data</PlayField>
    <PlayField ID="XInfo.XInfo_Unit" TS="">Offense</PlayField>
  </PlayFields>
</PlayAttributes>

1 个答案:

答案 0 :(得分:1)

可能值得查看XML Schema Definition Tool (xsd),尤其是关于example usage的部分:

  

以下命令从myFile.xml生成XML模式   将其保存到指定目录。

xsd myFile.xml /outputdir:myOutputDir