110,538
社区成员
发帖
与我相关
我的任务
分享
string temp = File.OpenText(@“D:\word.doc”).ReadToEnd();
//使用Framework类库封装的COM组件解析
using Microsoft.Office.Interop.Word;
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();//打开word程序
Microsoft.Office.Interop.Word.Document doc = null;//实例化一个新的word文档
object unknow = Type.Missing;
app.Visible = true;
doc = app.Documents.Open(ref fileName,
ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,
ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,
ref unknow,ref unknow,ref unknow,ref unknow,ref unknow);
string temp = doc.Content.Text.Trim();
//把word文档另存为xml,解析xml文件
using System.XML;
XmlDocument doc = new XmlDocument();
doc.Load(filePath); //载入XML文档
XmlElement root = doc.DocumentElement; //定义载入XML的根节点
foreach(XmlNode xn1 in root.ChildNodes) //对于根节点以外的子节点做循环,以下同理
{
//对元素处理~~~
}
http://bbs.csdn.net/topics/280041104