本文介绍了在C#中编辑ODC文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在c#中编辑.odc文件,我认为它会很简单,因为它只是xml,但是当我运行它时,它涉及到加载文档 xmlDoc.Load(THEFILE.odc )它给我一个错误:

'Content-Type'是一个意外的标记。预期的标记是'''或''',第5行,第18位。
这就是我在谈论文档本身的第5行第18行:

 < meta http-equiv = Content-Type content =text / x-ms-odc; charset = utf-8> 

这是一个odc文件,我需要通过连接属性并更改ConnectionString。感谢advace

 < html xmlns:o =urn:schemas- microsoft-com:office:office
xmlns =http://www.w3.org/TR/REC-html40>

< head>
< b< ; meta http-equiv = Content-Type content =text / x-ms-odc; charset = utf-8>
< meta name = ProgId content = ODC.Table>
< meta name = SourceType content = OLEDB>
< title> Title< / title> ;
< xml id = docprops>< o:DocumentProperties
xmlns:o =urn:schemas-microsoft-com:office:office
xmlns =http:// www .w3.org / TR / REC-html40>
< odc:Connection odc:Type =OLEDB>
< odc:ConnectionString>ConnectionString< / odc:ConnectionString> ;
< odc:CommandType> Table< / odc:CommandType>
< odc:CommandText>CommandText< / odc:CommandText>
< odc:SSOApplicationID> testReport< / odc:SSOApplicationID>
< odc:CredentialsMethod>存储< / odc:CredentialsMethod>
< / odc:连接>
< / odc:OfficeDataConnection>
< / xml>
<样式>
<! -
.ODCDataSource
{
行为:url(dataconn.htc);
}
- >
< / style>

< / head>
pre>

更多的文件本身,但上面是即时通讯尝试编辑的xml。



谢谢

解决方案

您的.ODC文件看起来像XML,但它不是。它不尊重一些XML规则。
例如meta标签没有关闭。

< meta name = ProgId content = ODC.Table>



$ < meta name =ProgIdcontent =ODC.Table/> (注意加引号和斜杠)

对于Content-Type的第一个错误;它应该是:
$ b

< meta http-equiv =Content-Typecontent =text / x-ms-odc; charset = utf-8/>
(Content-Type需要用引号(或单引号)包围)。

我建议你直接在中加载.ODC文件,或者在加载之前使用一些清理工具。


I am trying to edit an .odc file in c# i thought it would be simple because its just xml but when i run it and it comes to Load the document xmlDoc.Load("THEFILE.odc") it gives me an error:

'Content-Type' is an unexpected token. The expected token is '"' or '''. Line 5, position 18. And that is i figure talking about Line 5 position 18 of the doc itself which is:

<meta http-equiv=Content-Type content="text/x-ms-odc; charset=utf-8">

the file is below. it is an odc file. I need to go through the connection properties and change the ConnectionString. Thanks in advace

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/x-ms-odc; charset=utf-8">
<meta name=ProgId content=ODC.Table>
<meta name=SourceType content=OLEDB>
<title>Title</title>
<xml id=docprops><o:DocumentProperties
  xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns="http://www.w3.org/TR/REC-html40">
  <odc:Connection odc:Type="OLEDB">
   <odc:ConnectionString>"ConnectionString"</odc:ConnectionString>
   <odc:CommandType>Table</odc:CommandType>
   <odc:CommandText>"CommandText"</odc:CommandText>
   <odc:SSOApplicationID>testReport</odc:SSOApplicationID>
   <odc:CredentialsMethod>Stored</odc:CredentialsMethod>
  </odc:Connection>
 </odc:OfficeDataConnection>
</xml>
<style>
<!--
    .ODCDataSource
    {
    behavior: url(dataconn.htc);
    }
-->
</style>

</head>

Theres more to the file itself but above is the xml which im trying to edit.

Thanks

解决方案

Your .ODC file looks like XML but it's not. It doesn't respect some XML rules.For instance the meta tags are not closed.

<meta name=ProgId content=ODC.Table>

should be

<meta name="ProgId" content="ODC.Table"/> (notice the quotes and slash added)

And for the first error for Content-Type; it should be :

<meta http-equiv="Content-Type" content="text/x-ms-odc; charset=utf-8"/>(Content-Type need to be surrounded with quotes (or single quotes)).

I'd suggest you to load directly your .ODC file with HTML Agility Pack or use some cleansing tool before loading it.

这篇关于在C#中编辑ODC文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 17:40