Reputation: 3968
I have an XML file that has 9000 lines in it.
Each XML node has about 10 attributes in it.
One of the attributes is:
<CreatedDate>2009-10-26T02:39:24</CreatedDate>
What I need to do is change the format of the DateTime to:
<CreatedDate>27/05/2010 07:30:16</CreatedDate>
But I do not know how to do it.
I know I could write a Regex to identify each value that needs to be replaced, but how can make it only change the values I want and maintain the rest?
I have thought about writing a macro, but the document is too big to format in a way that I could predict where the element I want ot change is, and searching for something does not seem to work on a macro.
Any ideas? - I am sure it can be done.
Upvotes: 0
Views: 755
Reputation: 1153
If you want to change datetimes format only inside <CreatedDate>
tags, try the regex replace in Notepad++ like this:
Replace this:
<CreatedDate>(\d{4})\-(\d{2})\-(\d{2})T([\d\:]*)</CreatedDate>
With this:
<CreatedDate>$3/$2/$1 $4</CreatedDate>
We refer to each parentheses using a $ symbol and it's position, so we can use those values in the replacing result.
Upvotes: 2
Reputation: 3973
Find this
<CreatedDate>(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2})<\/CreatedDate>
Replace with:
<CreatedDate>\3/\2/\1 \4<\/CreatedDate>
Upvotes: 1
Reputation: 1043
Find:
<CreatedDate>(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)</CreatedDate>
Replace:
<CreatedDate>\3/\2/\1 \4:\5:\6</CreatedDate>
\d matches a Digit. And the braces create a group that you reference with e.g. \1
Upvotes: 2