1 回答
TA贡献1877条经验 获得超1个赞
我尝试使用XDocument获取值。
void Main()
{
var oneNoteProvider = new OneNoteProvider();
var pageitems = oneNoteProvider.PageItems.Where(p => p.Name =="TEST");
foreach (var item in pageitems)
{
var pageXMLContent = string.Empty;
oneNoteProvider.OneNote.GetPageContent(item.ID, out pageXMLContent, Microsoft.Office.Interop.OneNote.PageInfo.piBasic);
var xml = XDocument.Parse(pageXMLContent);
var ns = xml.Root.Name.Namespace;
var html = $@"
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:dt='uuid:{item.ID}' xmlns='http://www.w3.org/TR/REC-html40'>
<body style='font-family:Calibri;font-size:11.0pt'>
{
string.Join("<br>",xml.Descendants(ns + "T").Skip(1).Select(s=>s.Value)) //skip first one because it's title.
}
</body>
</html>".Dump();
}
}
查询结果:
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:dt='uuid:{1FA8749E-CCE5-4BC5-A803-60A7C569085E}{1}{E1954399447194725751151923730734807786438831}' xmlns='http://www.w3.org/TR/REC-html40'>
<body style='font-family:Calibri;font-size:11.0pt'>
<br><span style='font-weight:bold'>This is test Page</span>
</body>
</html>
这种方式或许是可能的。我正在尝试。
- 1 回答
- 0 关注
- 444 浏览
添加回答
举报