尝试将 XML 从 Sharepoint Web 服务调用加载到 ASP.NET Gridview 时出错

发布于 2024-07-19 04:06:27 字数 1366 浏览 7 评论 0原文

我收到错误:

路径中存在非法字符。

当尝试使用 XPath 将 XML 加载到我正在构建的 ASP.NET 页面的代码隐藏中的 PageLoad 函数中的 gridview 数据源中时。 有谁知道这个错误是什么意思?

来自 Sharepoint Web 服务调用的 XML 是:

<?xml version='1.0' encoding='ISO-8859-1'?>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
<rs:data ItemCount="2"> 
    <z:row ows_Attachments="0" ows_LinkTitle="testTitle" ows_IncidentID="0" .../> 
    <z:row ows_Attachments="0" ows_LinkTitle="test2" ows_IncidentID="1" ... /> 
</rs:data> 

我后面的代码是:

newNode = thisL.GetListItems(strID, viewName, query, viewFields, rowLimit, queryOptions, webID)

    mNodeList = newNode.ChildNodes
    Dim ds_me As New Data.DataSet

    xdsIncidents.Data = "<?xml version='1.0' encoding='utf-8'?>" & newNode.OuterXml
    xdsIncidents.XPath = "//z:row"
    GridView1.AutoGenerateColumns = True
    DataDiv.InnerText = xdsIncidents.Data

    ds_me.ReadXml(xdsIncidents.Data)
    Dim dv As New Data.DataView(ds_me.Tables(1))

    GridView1.DataSource = dv
    GridView1.DataBind()

错误消息出现在“ds_me.ReadXML...”行上

I'm getting the error:

Illegal characters in path.

when trying to load XML, using XPath, into a gridview's datasource in the PageLoad function in the code-behind of an ASP.NET page I'm building. Does anyone know what this error means?

The XML coming in from the Sharepoint Web Services call is:

<?xml version='1.0' encoding='ISO-8859-1'?>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
<rs:data ItemCount="2"> 
    <z:row ows_Attachments="0" ows_LinkTitle="testTitle" ows_IncidentID="0" .../> 
    <z:row ows_Attachments="0" ows_LinkTitle="test2" ows_IncidentID="1" ... /> 
</rs:data> 

And my code behind is:

newNode = thisL.GetListItems(strID, viewName, query, viewFields, rowLimit, queryOptions, webID)

    mNodeList = newNode.ChildNodes
    Dim ds_me As New Data.DataSet

    xdsIncidents.Data = "<?xml version='1.0' encoding='utf-8'?>" & newNode.OuterXml
    xdsIncidents.XPath = "//z:row"
    GridView1.AutoGenerateColumns = True
    DataDiv.InnerText = xdsIncidents.Data

    ds_me.ReadXml(xdsIncidents.Data)
    Dim dv As New Data.DataView(ds_me.Tables(1))

    GridView1.DataSource = dv
    GridView1.DataBind()

The error message is coming up on the line "ds_me.ReadXML..."

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

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

发布评论

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

评论(1

诗化ㄋ丶相逢 2024-07-26 04:06:27

这是因为 ReadXml 的重载期望从中读取某些 xml 的文件路径,而不是其中包含 xml 的字符串。

如果您想以这种方式加载数据集,则需要从字符串创建 XmlReader 或 TextReader。

This is because that overload of ReadXml is expecting a file path to read some xml from, not a string with xml in it.

You'll need to create an XmlReader or TextReader from your string if you want to load the DataSet in this way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文