Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将html转换为具有所有格式的word文档_C#_Html_Xml_Infopath2010 - Fatal编程技术网

C# 将html转换为具有所有格式的word文档

C# 将html转换为具有所有格式的word文档,c#,html,xml,infopath2010,C#,Html,Xml,Infopath2010,我必须用C#从这个XML文件中读取以下html 然后,tc.key\u可交付成果将html作为字符串包含 请建议我如何进行这项工作 如果您可以访问Word COM或使用VSTO,您可以使用Word打开html文件(或将html内容输出到新文档中),然后使用Word对象模型另存为docs/docx 其他方法: 如果我只需要从HTML获取文本,这些功能就可以工作。然而,在我的例子中,文档已经创建了&我必须将从HTML提取的格式化文本添加到现有文档中。所有这些都可以很好地进行格式化。图像可能会

我必须用C#从这个XML文件中读取以下html

然后,tc.key\u可交付成果将html作为字符串包含


请建议我如何进行这项工作

如果您可以访问Word COM或使用VSTO,您可以使用Word打开html文件(或将html内容输出到新文档中),然后使用Word对象模型另存为docs/docx

其他方法:


如果我只需要从HTML获取文本,这些功能就可以工作。然而,在我的例子中,文档已经创建了&我必须将从HTML提取的格式化文本添加到现有文档中。所有这些都可以很好地进行格式化。图像可能会导致问题,但不是通过第一种方法-Word使用图像正确打开html内容。
<?xml version="1.0" encoding="utf-8"?>
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:TestCRForm:-myXSD-2013-01-09T15-23-27" solutionVersion="1.0.0.285" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://win-rskupn6mf2b:2331/TestCRForm/Forms/template.xsn"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:tns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-01-09T15:23:27" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
    <my:VendorName>Vendor Name1</my:VendorName>
    <my:Assignedto>Asigner</my:Assignedto>
    <my:SOWNumber></my:SOWNumber>
    <my:DraftStarted xsi:nil="true"></my:DraftStarted>
    <my:DateComplete xsi:nil="true"></my:DateComplete>
    <my:GLCode>Material No1</my:GLCode>
    <my:LogID>2013-09-05T22:44:09</my:LogID>
    <my:Status>New</my:Status>
    <my:ProjectDescription>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve"><div><em>This is Project Deliverable Info</em></div><div><span id="ms-rterangepaste-start"></span><span id="ms-rterangepaste-end"></span><div><em>Whjoa</em></div><div><strong><em>Dude</em></strong></div></div></html>
  </my:ProjectDescription>

</my:myFields>
XmlNodeList nodelist3 = xml.SelectNodes("my:myFields/my:ProjectDeliverables", nsm);
                foreach (XmlNode node in nodelist3)
                    tc.key_deliverables = node.InnerXml;