I have an XML file of format,
{XML file with similar tags - SubRecord and Property}
...
<SubRecord>
<Property Name="Name">My Main Search Keyword</Property>
<Property Name="Prompt">Dummy</Property>
<Property Name="Default">Value i'm Concerned to Modify</Property>
</SubRecord>
...
My req. is to get the value of the "Default" for this particular sub-record and update it based on condition. For that i need to get to this particular tag "Name" and modify its value.
Is there way using SED/AWK/GREP?
EDIT: As per @terdon's update:
- Will all sections be one line only? No
- Will the default always be the last? Always third from top (Name, Prompt, Default)
- Is anything case sensitive? Is everything? Case Sensitive.
- Are there blank lines? Hopefully No. But i can do some pre-possessing to remove them.
- Is the file indented? Yes.
Example: ...
<SubRecord>
<Property Name="Name">Search</Property>
<Property Name="Prompt">Some Text</Property>
<Property Name="Default">abc.txt</Property>
</SubRecord>
...
In a large XML file with similar Propert and SubRecords, i need to first find all the properties of "Search" parameter.
On finding "Search" i then need to check its default value. If it is abc.txt, then i need to retain that value, if it is xyx, still i need to retain. Other than abc.txt or xyz, i need to update it with abc.txt.