anand1
12 years agoContributor
[Resolved] Replace node in XML
I have a XML which contains multiple tags, the hierarchy is somewhat like this
<PlayerInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/nConnect.Resources.PlayerInfo.Entities">
<ClientID i:nil="true"/>
<DateTime>0001-01-01T00:00:00</DateTime>
<ErrorCode i:nil="true"/>
<ErrorText i:nil="true"/>
<PropertyId i:nil="true"/>
<ReplyToSystem i:nil="true"/>
<UserID i:nil="true"/>
<VendorName i:nil="true"/>
<Address>
<PlayerAddress>
<AddressActive>true</AddressActive>
<AddressCareOf>Naomi Campbell</AddressCareOf>
<AddressCity>Little Rock</AddressCity>
<AddressComment>**Mailing Comments**</AddressComment>
<AddressId i:nil="true"/>
<AddressLine1>111 Street</AddressLine1>
<AddressLine2>112 Street</AddressLine2>
<AddressLine3>113 Street</AddressLine3>
<AddressLine4>114 Street</AddressLine4>
<AddressSuburb>Sector-11</AddressSuburb>
<AddressType>Mail<AddressType>
<CountryCode>US</CountryCode>
</PlayerAddress>
</PlayerInfo>
Now i have to change the value of AddressType from "mail" to <AddressType i:nil="true"/> in groovy, how should I go about it.
I can easily remove this node, however not able to replace the same.
<PlayerInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/nConnect.Resources.PlayerInfo.Entities">
<ClientID i:nil="true"/>
<DateTime>0001-01-01T00:00:00</DateTime>
<ErrorCode i:nil="true"/>
<ErrorText i:nil="true"/>
<PropertyId i:nil="true"/>
<ReplyToSystem i:nil="true"/>
<UserID i:nil="true"/>
<VendorName i:nil="true"/>
<Address>
<PlayerAddress>
<AddressActive>true</AddressActive>
<AddressCareOf>Naomi Campbell</AddressCareOf>
<AddressCity>Little Rock</AddressCity>
<AddressComment>**Mailing Comments**</AddressComment>
<AddressId i:nil="true"/>
<AddressLine1>111 Street</AddressLine1>
<AddressLine2>112 Street</AddressLine2>
<AddressLine3>113 Street</AddressLine3>
<AddressLine4>114 Street</AddressLine4>
<AddressSuburb>Sector-11</AddressSuburb>
<AddressType>Mail<AddressType>
<CountryCode>US</CountryCode>
</PlayerAddress>
</PlayerInfo>
Now i have to change the value of AddressType from "mail" to <AddressType i:nil="true"/> in groovy, how should I go about it.
I can easily remove this node, however not able to replace the same.