Replace text in .xml file when find matching value in one field but need to update data in another field
Posted: Mon Dec 21, 2015 9:31 am
Hi, I have spent much time trying to figure out how to do this. I will do my best to explain what I am trying to do. Below is a single row of data from the .xml file I am trying to update:
<Row AreaParentID="2" ChildAreaID="2" ParentAreaID="1" StartDate="1986-06-01T00:00:00" CreateDate="2013-10-17T14:28:01.24" ChangeDate="2013-10-17T14:28:01.24" CreateWorkstationID="12345" ChangeWorkstationID="12345"/>
There will only ever be one row in the file that will match what I am looking for. What I need to do is find a given AreaParentID and then either update the StartDate or remove the start date from the row that was found. I have seen all sorts of examples using creplace and even RegEx, but they have all been fairly simplistic updating the same field that is being searched. Oh, I am not good with regular expressions and have never really used one in PowerShell.
Thanks in advance for any help provided!
Tim
<Row AreaParentID="2" ChildAreaID="2" ParentAreaID="1" StartDate="1986-06-01T00:00:00" CreateDate="2013-10-17T14:28:01.24" ChangeDate="2013-10-17T14:28:01.24" CreateWorkstationID="12345" ChangeWorkstationID="12345"/>
There will only ever be one row in the file that will match what I am looking for. What I need to do is find a given AreaParentID and then either update the StartDate or remove the start date from the row that was found. I have seen all sorts of examples using creplace and even RegEx, but they have all been fairly simplistic updating the same field that is being searched. Oh, I am not good with regular expressions and have never really used one in PowerShell.
Thanks in advance for any help provided!
Tim