我一直在尝试学习 Open XML,并在 Visual Studio c# 中成功生成了一个自由文本 2007 .docx 文件。之后,我将文件以 .xml 格式保存在 Word 中,然后将 .xml 文件导入 sql server 2012 到名为 XML 的表中到名为 xml 的列中:这是表的代码:
CREATE TABLE [dbo].[XML](
[XML_ID] [int] IDENTITY(1,1) NOT NULL,
[XML] [xml] NOT NULL,
CONSTRAINT [PK_XML] PRIMARY KEY CLUSTERED
(
[XML_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
这是我运行的插入
INSERT INTO XML(XML)
SELECT * FROM OPENROWSET(
BULK 'C:\Users\bbt2d\Desktop\Document.xml',
SINGLE_BLOB) AS x;
当我运行一个 select * 时,xml 文件出现了,但是当我尝试从段落中查询一些数据时,我没有得到任何结果。
这是存储在 sql server 中的 xml 的部分截图:想知道我是否执行了错误的过程,或者您将如何从文档中查询文本。
?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" />
</Relationships>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml" />
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml" />
<Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer1.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml" />
<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" Target="endnotes.xml" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" Target="footnotes.xml" />
<Relationship Id="rId10" Type="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects" Target="stylesWithEffects.xml" />
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml" />
<Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
</Relationships>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
<pkg:xmlData>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
<w:p w:rsidR="00C32D34" w:rsidRDefault="00C32D34">
<w:pPr>
<w:pStyle w:val="Heading1" />
<w:spacing w:line="240" w:lineRule="auto" />
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" />
<w:sz w:val="44" />
<w:szCs w:val="44" />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" />
<w:sz w:val="44" />
<w:szCs w:val="44" />
</w:rPr>
<w:t>School District of Marshfield</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00C32D34" w:rsidRDefault="00C32D34">
<w:pPr>
<w:autoSpaceDE w:val="0" />
<w:autoSpaceDN w:val="0" />
<w:adjustRightInd w:val="0" />
<w:spacing w:after="0" w:line="240" w:lineRule="auto" />
<w:rPr>
<w:rFonts w:ascii="Cambria" w:hAnsi="Cambria" w:cs="Cambria" />
<w:b />
<w:bCs />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
</w:pPr>
</w:p>
<w:p w:rsidR="00C32D34" w:rsidRDefault="00DE219B">
<w:pPr>
<w:autoSpaceDE w:val="0" />
<w:autoSpaceDN w:val="0" />
<w:adjustRightInd w:val="0" />
<w:spacing w:after="0" w:line="240" w:lineRule="auto" />
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Cambria" w:hAnsi="Cambria" w:cs="Cambria" />
<w:b />
<w:bCs />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Cambria" w:hAnsi="Cambria" w:cs="Cambria" />
<w:b />
<w:bCs />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
<w:t>Exploring French</w:t>
</w:r>
<w:r w:rsidR="00C32D34">
<w:rPr>
<w:rFonts w:ascii="Cambria" w:hAnsi="Cambria" w:cs="Cambria" />
<w:b />
<w:bCs />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
<w:t xml:space="preserve"> & Spanish</w:t>
</w:r>