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
如何从powershell中的多个xml节点项(具有名称空间)列表中仅获取第一个xml节点项_Xml_Powershell_Xml Namespaces - Fatal编程技术网

如何从powershell中的多个xml节点项(具有名称空间)列表中仅获取第一个xml节点项

如何从powershell中的多个xml节点项(具有名称空间)列表中仅获取第一个xml节点项,xml,powershell,xml-namespaces,Xml,Powershell,Xml Namespaces,我的xml文件内容(testdata.xml)如下所示 <wd:Report_Data xmlns:wd="urn:com.mycomp.report/Get-Integration-Events"> <wd:Report_Entry> <wd:Integration_Event>SomeInfo - 04/17/2017 11:29:14.061 (Completed)</wd:Integration_Event>

我的xml文件内容(testdata.xml)如下所示

<wd:Report_Data xmlns:wd="urn:com.mycomp.report/Get-Integration-Events">
    <wd:Report_Entry>
        <wd:Integration_Event>SomeInfo - 04/17/2017 11:29:14.061 (Completed)</wd:Integration_Event>
        <wd:Integration_ID>123456789a123</wd:Integration_ID>
        <wd:Integration_Event_Status>Completed</wd:Integration_Event_Status>
        <wd:Actual_Start_Date_and_Time>2017-04-17T11:29:00-07:00</wd:Actual_Start_Date_and_Time>
        <wd:Actual_Completed_Date_and_Time>2017-04-17T11:29:23.085-07:00</wd:Actual_Completed_Date_and_Time>
        <wd:Request_Name>
            SomeInfo - 04/17/2017 11:29:14.061 (Completed)
        </wd:Request_Name>
        <wd:Response_Message>Integration Completed.</wd:Response_Message>
        <wd:referenceID>SomeRefId</wd:referenceID>
    </wd:Report_Entry>
    <wd:Report_Entry>
        <wd:Integration_Event>SomeInfo - 04/17/2017 11:29:14.061 (Completed)</wd:Integration_Event>
        <wd:Integration_ID>234567890b234</wd:Integration_ID>
        <wd:Integration_Event_Status>Completed</wd:Integration_Event_Status>
        <wd:Actual_Start_Date_and_Time>2017-04-17T11:29:00-07:00</wd:Actual_Start_Date_and_Time>
        <wd:Actual_Completed_Date_and_Time>2017-04-17T11:29:23.085-07:00</wd:Actual_Completed_Date_and_Time>
        <wd:Request_Name>
            SomeInfo - 04/17/2017 11:29:14.061 (Completed)
        </wd:Request_Name>
        <wd:Response_Message>Integration Completed.</wd:Response_Message>
        <wd:referenceID>SomeRefId</wd:referenceID>
    </wd:Report_Entry>
    <wd:Report_Entry>
        ............. around 50+ similar entries
    </wd:Report_Entry>
</wd:Report_Data>

如何使用powershell实现此功能?

$confXml.GetElementsByTagName(“wd:Integration\u Event\u Status”)[0]。#text'
Thank@MathiasR.Jessen还有如何提取第一次出现的标记的所有子元素?
$baseDir = "C:\myfolder"
$configFile = "$baseDir\testdata.xml"
[xml]$confXml = Get-Content $configFile
$eventStatus = $confXml.GetElementsByTagName("wd:Integration_Event_Status").'#text'
Write-Host $eventStatus