代码之家  ›  专栏  ›  技术社区  ›  SMUsamaShah

用C将XML直接保存到数据库#

  •  1
  • SMUsamaShah  · 技术社区  · 15 年前

    <teams>
      <team-profile>
        <name>Australia</name>
        <id>1</id>
        <stats type="Test">
          <span>1877-2010</span>
          <matches>721</matches>
          <won>339</won>
          <lost>186</lost>
          <tied>2</tied>
          <draw>194</draw>
          <percentage>47.01</percentage>
        </stats>
        <squad>
          <player id="135" fullname="Shane Warne"/>
          <player id="136" fullname="Damien Martyn"/>
          <player id="138" fullname="Michael Clarke"/>
        </squad>
      </team-profile>
    </team>
    

    我在某个地方读到,有一种方法可以将这个XML直接保存到数据库中。我正在使用VS2010。我已经创建了数据集,用于从这个xml中获取所需的数据。有什么方法可以直接将这个XML映射到数据集上吗? 还有别的主意吗? 我还必须将其他一些更复杂的XML文件保存到数据库中。

    我已尝试xsd.exe为此XML创建xsd架构。

    1 回复  |  直到 15 年前
        1
  •  3
  •   Ta01    15 年前

    insert

    INSERT INTO docs VALUES (1, '<book genre="security"
    publicationdate="2002" ISBN="0-7356-1588-2">
       <title>Writing Secure Code</title>
       <author>
          <first-name>Michael</first-name>
          <last-name>Howard</last-name>
       </author>
       <author>
          <first-name>David</first-name>
          <last-name>LeBlanc</last-name>
       </author>
       <price>39.99</price>
    </book>')
    INSERT INTO docs VALUES (2, 
    '<doc id="123">
        <sections>
       <section num="1"><title>XML Schema</title></section>
       <section num="3"><title>Benefits</title></section>
       <section num="4"><title>Features</title></section>
        </sections>
    </doc>')
    
    推荐文章