Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
Linq To Xml在不知道确切结构的情况下搜索Xml_Xml_Linq To Xml_Recursive Query - Fatal编程技术网

Linq To Xml在不知道确切结构的情况下搜索Xml

Linq To Xml在不知道确切结构的情况下搜索Xml,xml,linq-to-xml,recursive-query,Xml,Linq To Xml,Recursive Query,如何解析以下内容以获取sql消息.Net SqlClient数据提供程序 我正在尝试使用LINQtoXML实现这一点,但运气不太好。xml是递归的,因此我无法确定消息将显示在哪个级别 有什么想法吗 谢谢 <detail> <ErrorCode xmlns="http://www.microsoft.com/sql/reportingservices">rsProcessingAborted</ErrorCode> <HttpStatus

如何解析以下内容以获取sql消息.Net SqlClient数据提供程序

我正在尝试使用LINQtoXML实现这一点,但运气不太好。xml是递归的,因此我无法确定消息将显示在哪个级别

有什么想法吗

谢谢

<detail>
    <ErrorCode xmlns="http://www.microsoft.com/sql/reportingservices">rsProcessingAborted</ErrorCode>
    <HttpStatus xmlns="http://www.microsoft.com/sql/reportingservices">400</HttpStatus>
    <Message xmlns="http://www.microsoft.com/sql/reportingservices">An error has occurred during report processing.</Message>
    <HelpLink xmlns="http://www.microsoft.com/sql/reportingservices">http://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsProcessingAborted&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=10.50.1600.1</HelpLink>
    <ProductName xmlns="http://www.microsoft.com/sql/reportingservices">Microsoft SQL Server Reporting Services</ProductName>
    <ProductVersion xmlns="http://www.microsoft.com/sql/reportingservices">10.50.1600.1</ProductVersion>
    <ProductLocaleId xmlns="http://www.microsoft.com/sql/reportingservices">1033</ProductLocaleId>
    <OperatingSystem xmlns="http://www.microsoft.com/sql/reportingservices">OsIndependent</OperatingSystem>
    <CountryLocaleId xmlns="http://www.microsoft.com/sql/reportingservices">1033</CountryLocaleId>
    <MoreInformation xmlns="http://www.microsoft.com/sql/reportingservices">

        <Source>Microsoft.ReportingServices.ProcessingCore</Source>
        <Message msrs:ErrorCode="rsProcessingAborted" msrs:HelpLink="http://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsProcessingAborted&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=10.50.1600.1" xmlns:msrs="http://www.microsoft.com/sql/reportingservices">An error has occurred during report processing.</Message>
        <MoreInformation>
            <Source>Microsoft.ReportingServices.ProcessingCore</Source>
            <Message msrs:ErrorCode="rsErrorReadingNextDataRow" msrs:HelpLink="http://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsErrorReadingNextDataRow&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=10.50.1600.1" xmlns:msrs="http://www.microsoft.com/sql/reportingservices">Cannot read the next data row for the dataset DD_Inventory.</Message>
            <MoreInformation>
                <Source>.Net SqlClient Data Provider</Source>
                <Message>Conversion failed when converting the nvarchar value 'h' to data type int.</Message>
            </MoreInformation>
        </MoreInformation>
    </MoreInformation>
    <Warnings xmlns="http://www.microsoft.com/sql/reportingservices" />
</detail>

rsProcessingAborted
400
报表处理过程中发生错误。
http://go.microsoft.com/fwlink/?LinkId=20476&EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorString&;EvtID=rsProcessingAborted&;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&;ProdVer=10.50.1600.1
Microsoft SQL Server报告服务
10.50.1600.1
1033
依赖于
1033
Microsoft.ReportingServices.ProcessingCore
报表处理过程中发生错误。
Microsoft.ReportingServices.ProcessingCore
无法读取数据集DD\U清单的下一个数据行。
.Net SqlClient数据提供程序
将nvarchar值“h”转换为数据类型int时,转换失败。
var doc=XDocument.Parse(xml);
XNS=”http://www.microsoft.com/sql/reportingservices";
字符串消息=(来自文档子体中的信息(ns+“MoreInformation”)
其中info.Element(ns+“MoreInformation”)==null
选择(字符串)info.Element(ns+“Message”).Single();
获取整个文档中名为
MoreInformation
的所有元素,仅获取其中没有嵌套任何
MoreInformation
的元素。对于他们,选择消息。最后,确保只有一个结果