open xml sdk可以用来创建xml文件吗?

发布于 2024-10-06 19:11:16 字数 145 浏览 0 评论 0原文

是否可以使用 OPEN XML SDK 并生成包含特定 docx 文件的一些元数据的 xml 文件?

详细信息:我有一个 docx 文件,我想从中提取一些元数据(使用打开的 xml)并将它们显示为 xml 文件,然后使用 Jquery 以更易读的形式呈现它们。

is it possible to use the OPEN XML SDK and generate an xml file that contains some metadata of a particular docx file?

details: i have a docx file, from which i want to extract some metadata(using open xml) and display them as xml file and later use Jquery to present them in a more readable form.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掀纱窥君容 2024-10-13 19:11:16

您可以使用 SDK 从 docx 中可能存在的各种属性部分提取信息(例如,核心属性部分,其中包括都柏林核心类型信息)。

您可以以其本机 XML 形式提取它:

    <cp:coreProperties          
            xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-                    properties" 
            xmlns:dc="http://purl.org/dc/elements/1.1/" .. >
       <dc:creator>Joe</dc:creator>
       <cp:lastModifiedBy>Joe</cp:lastModifiedBy>
       <cp:revision>1</cp:revision>
       <dcterms:created xsi:type="dcterms:W3CDTF">2010-11-10T00:32:00Z</dcterms:created>
       <dcterms:modified xsi:type="dcterms:W3CDTF">2010-11-10T00:33:00Z</dcterms:modified>
   </cp:coreProperties>

或者以您自己选择的其他 XML 方言形式提取它。

You can use the SDK to extract info from the various properties parts which may be present in the docx (for example, the core properties part, which included dublin core type info).

You can extract it in its native XML form:

    <cp:coreProperties          
            xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-                    properties" 
            xmlns:dc="http://purl.org/dc/elements/1.1/" .. >
       <dc:creator>Joe</dc:creator>
       <cp:lastModifiedBy>Joe</cp:lastModifiedBy>
       <cp:revision>1</cp:revision>
       <dcterms:created xsi:type="dcterms:W3CDTF">2010-11-10T00:32:00Z</dcterms:created>
       <dcterms:modified xsi:type="dcterms:W3CDTF">2010-11-10T00:33:00Z</dcterms:modified>
   </cp:coreProperties>

or, in some other XML dialect of your own choosing.

胡大本事 2024-10-13 19:11:16

我知道问题很久以前就发布了,但是谷歌搜索的第一个结果将我发送到这里。因此,如果还有其他人正在寻找解决方案,MSDN 网站上有一个片段 https://msdn.microsoft.com/en-us/library/office/cc489219.aspx

简短的答案是...使用 XmlTextWritter,它适用于 Office 2013 afaik:

// Add the CoreFilePropertiesPart part in the new word processing document.
var coreFilePropPart = wordDoc.AddCoreFilePropertiesPart();
using (XmlTextWriter writer = new XmlTextWriter(coreFilePropPart.GetStream(FileMode.Create), System.Text.Encoding.UTF8))
{
    writer.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"></cp:coreProperties>");
    writer.Flush();
}

I know question was posted a long time ago, but first result of google search sent me here. So if there are others looking for a solution to this, there is a snippet on MSDN website https://msdn.microsoft.com/en-us/library/office/cc489219.aspx

short answer is... using XmlTextWritter, and it applies to Office 2013 afaik:

// Add the CoreFilePropertiesPart part in the new word processing document.
var coreFilePropPart = wordDoc.AddCoreFilePropertiesPart();
using (XmlTextWriter writer = new XmlTextWriter(coreFilePropPart.GetStream(FileMode.Create), System.Text.Encoding.UTF8))
{
    writer.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"></cp:coreProperties>");
    writer.Flush();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文