I have XML content which I need to remove whole line from a particular element from a node.
XML File:
need remove whole line.
<Host name="login.net">
<Path name="Block">
<Path name="webservices/login" authType="qwerty" requireSession="true" />
<Path name="login" authType="qwerty" requireSession="true" />
<Path name="weblogin" requireSession="true" authType="shibboleth" />
</Path>
<Path name="retailpdf" applicationId="retailpdf" authType="qwerty" requireSession="true" requireSessionWith="retailpdf" />
<Path name="managemyaccount" applicationId="managemyaccount" authType="qwerty" requireSession="true" requireSessionWith="managemyaccount" />
<Path name="approve" applicationId="approve" authType="qwerty" requireSession="true" requireSessionWith="approve" />
<Path name="latesignin" applicationId="latesignin" authType="qwerty" requireSession="true" requireSessionWith="latesignin" />
<Path name="fblogin" applicationId="fblogin" authType="qwerty" requireSession="true" requireSessionWith="fblogin" />
</Host>
</RequestMap>
# need to remove complete node of id retailpdf
Tried to remove the lines through powershell script
$XMLfilepath = 'C:\Test\MYfile.xml'
psedit $XMLfilepath
$Pathxml = [xml] (Get-Content $XMLfilepath)
$nodes = $xml.SelectNodes("/RequestMapper/Path");
{Remove-Item "<Path name="fblogin" applicationId="fblogin" authType="shibboleth" requireSession="true" requireSessionWith="fblogin" />"}
$XMLfilepathNew = 'C:\Test\Myfiledone.xml'
$Pathxml.Save($XMLfilepathNew)
psedit $XMLfilepathNew
Need to remove mentioned line and node in XML content like below:
Expected output:
<Host name="login.net">
<Path name="Block">
<Path name="webservices/login" authType="qwerty" requireSession="true" />
<Path name="login" authType="qwerty" requireSession="true" />
<Path name="weblogin" requireSession="true" authType="shibboleth" />
</Path>
<Path name="managemyaccount" applicationId="managemyaccount" authType="qwerty" requireSession="true" requireSessionWith="managemyaccount" />
<Path name="approve" applicationId="approve" authType="qwerty" requireSession="true" requireSessionWith="approve" />
<Path name="latesignin" applicationId="latesignin" authType="qwerty" requireSession="true" requireSessionWith="latesignin" />
<Path name="fblogin" applicationId="fblogin" authType="qwerty" requireSession="true" requireSessionWith="fblogin" />
</Host>
</RequestMap>
<ApplicationOverride id="retailpdf" entityID="https://login.tcxqa.hrblock.net/retailpdf/shibboleth">
<Sessions lifetime="60" timeout="20" checkAddress="false" consistentAddress="false" handlerURL="/retailpdf/Shibboleth.sso" handlerSSL="true">
<SessionInitiator type="Chaining" Location="/retailpdf" isDefault="false" id="retailpdf" forceAuthn="true" entityID="https://qaidp.hrblock.net/idp/shibboleth" authnContextClassRef="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport">
<SessionInitiator type="SAML2" template="bindingTemplate.html" />
</SessionInitiator>
</Sessions>