0

我有一个 docx 格式的 word 文档,其中的数据采用重复格式模式。

我想从重复集中获取每个数据并上传到 SQL 表中的一行。

这里的数据样本:

Question No : 1
How is LINQ to SQL different from Entities?

A. Answer 1
B. Answer 1
C. Answer 1
D. Answer 1

Answer : D
Explanations : 
Some explanation.

Question No : 2
How is NVARCHAR different from VARCHAR

A. Answer 1
B. Answer 1
C. Answer 1
D. Answer 1

Answer : D
Explanations : 
Some explanation.

我可以想到几种方法:
- 使用 Office API 将文档读取为 docx
- 从 Word 将文档另存为 XML 并解析 XML [转换后的 XML 文档似乎没有结构/架构]
- 将文档另存为 HTML Word 和解析 HTML [DOM 结构格式不正确]

您会建议以上哪一项,为什么?是否有任何工具可以帮助转换文档并上传到 SQL 表或访问数据库?

谢谢!

4

2 回答 2

3

DOCX 只是 XML 文件的 ZIP 目录树。使用 WinZip 或 7-Zip 将其解压缩到一组子目录中。将这些 XML 文件上传到 SQL Server,添加它们的文件名和文件夹路径。使用 SQL Server XML 方法(.node 等)将它们分解成您想要的关系形式。

请注意,它们确实具有 XML 模式和结构。

于 2009-08-17T04:55:25.063 回答
1

If you are going to process these files not very often, then I'd say save it to a different format (easier to process by SQL) - maybe even a plain text format. If this process (of importing this file to DB) is going to be performed on a regular basis - go for the native DOCX processing without converting it to a intermediate format. Quick Google search revealed that there are components available that can read docx format into a database (e.g. http://www.brothersoft.com/code-library-for-.net-(sql-server-msde)-22050.html)

于 2009-08-17T06:33:59.887 回答