Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
SSRS将报告导出为XML并删除元素_Xml_Reporting Services_Export To Xml - Fatal编程技术网

SSRS将报告导出为XML并删除元素

SSRS将报告导出为XML并删除元素,xml,reporting-services,export-to-xml,Xml,Reporting Services,Export To Xml,我正在尝试使用订阅在SSRS中设置一个报告,以将一些数据导出为XML文件,以便将其导入到另一个应用程序中。然而,report元素导致了整个过程的失败 我的输出是: <?xml version="1.0" encoding="utf-8" ?> <Report xsi:schemaLocation="BO http://reportserver?%2FBO.BILLING%20BacklogTest&rs%3AFormat=XML&rc%3ASchema=Tru

我正在尝试使用订阅在SSRS中设置一个报告,以将一些数据导出为XML文件,以便将其导入到另一个应用程序中。然而,report元素导致了整个过程的失败

我的输出是:

<?xml version="1.0" encoding="utf-8" ?> 
<Report xsi:schemaLocation="BO http://reportserver?%2FBO.BILLING%20BacklogTest&rs%3AFormat=XML&rc%3ASchema=True" Name="BO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="BO">
    <ForecastGroups>
        <ForecastGroup>
        <Code>BO.BILLING</Code> 
            <ActualOutstandingTasks>
            <TimeStamp>2015-09-25T00:00:00</TimeStamp> 
                <ArrivalPeriods>
                    <ArrivalPeriod>
                    <StopTime>2015-09-25T00:00:00</StopTime> 
                    <StartTime>2015-09-24T00:00:00</StartTime> 
                    <Tasks>2074</Tasks> 
                    </ArrivalPeriod>
                </ArrivalPeriods>
            </ActualOutstandingTasks>
        </ForecastGroup>
    </ForecastGroups>
  </Report>
除非我手动删除report元素,否则它不会工作。我需要输出为:

<?xml version="1.0" encoding="utf-8"?>
<ForecastGroups>
    <ForecastGroup>
        <Code>BO.BILLING</Code>
        <ActualOutstandingTasks>
            <TimeStamp>2015-09-25T00:00:00</TimeStamp>
            <ArrivalPeriods>
                <ArrivalPeriod>
                    <StopTime>2015-09-25T00:00:00</StopTime>
                    <StartTime>2015-09-24T00:00:00</StartTime>
                    <Tasks>2074</Tasks>
                </ArrivalPeriod>
            </ArrivalPeriods>
        </ActualOutstandingTasks>
    </ForecastGroup>
</ForecastGroups>
然后它工作得很好。SSRS中是否有方法阻止报表元素呈现

谢谢, Greville

考虑使用一种声明性模板语言,用于以任何方式、形状或形式转换XML内容

当然,您需要一个XSLT处理器来读取原始的.xml文件,使用below.xsl文件进行转换,并输出最终的.xml文件。实际上,所有现代编程语言都维护XSLT库Java、C、Python、PHP甚至VBA,因为您可以使用日常MS Access或MS Excel运行:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xsi:schemaLocation="BO http://reportserver?%2FBO.BILLING%20BacklogTest&amp;rs%3AFormat=XML&amp;rc%3ASchema=True"
       Name="BO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bo="BO"> 
<xsl:output version="1.0" encoding="UTF-8"/>

<xsl:template match="bo:Report">
    <xsl:copy-of select="bo:ForecastGroups"/>
</xsl:template>

</xsl:transform>

顺便说一句,原始XML的schemaLocation路径需要符号和字符&转义为&

不起作用?导入应用程序是否引发错误?它是什么?它正在寻找ForecastGroups作为第一个元素,并声明如果report元素在那里它就找不到它。我尝试将报表的DataElementName属性更改为ForecastGroups,并删除其下的ForecastGroup。但是也出现了同样的错误。请注意,SSRS渲染引擎已经支持XLST,因此您可以在不需要自定义代码的情况下应用该脚本,例如@MikeHoney,甚至更好!因此OP有各种方法来处理XML重构。
<?xml version='1.0' encoding='UTF-8'?>
<ForecastGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="BO">
        <ForecastGroup>
        <Code>BO.BILLING</Code> 
            <ActualOutstandingTasks>
            <TimeStamp>2015-09-25T00:00:00</TimeStamp> 
                <ArrivalPeriods>
                    <ArrivalPeriod>
                    <StopTime>2015-09-25T00:00:00</StopTime> 
                    <StartTime>2015-09-24T00:00:00</StartTime> 
                    <Tasks>2074</Tasks> 
                    </ArrivalPeriod>
                </ArrivalPeriods>
            </ActualOutstandingTasks>
        </ForecastGroup>
    </ForecastGroups>