Solved

XML search and replace

Posted on 2013-10-25
1
205 Views
Last Modified: 2015-01-13
I have an XML document with the following dates and periods.  It is run twice a month.

An example of the lines are as follows:

<DOC_REC_DT_DC Attribute="Y"><![CDATA[2013-10-15]]></DOC_REC_DT_DC>
<DOC_PER_DC Attribute="Y"><![CDATA[1]]></DOC_PER_DC>
<BFY Attribute="Y"><![CDATA[2014]]></BFY>

There are about 10 different dates that have to be changed and each of these lines are in the document an unknown number of times.  For example, doing this manually, I find the first occurrence of <DOC_REC_DT_DC... and replace all with the same text except for changing the date from 2013-10-15 to the current date.

I would like to automate this so it doesn't have to be done manually.

I don't know xml so I'd like to use a batch file or some reliable utility.

Thank you for your help.
0
Comment
Question by:schowning
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
mark_harris231 earned 500 total points
ID: 39601479
I would suggest using a text editor like Programmer's Notepad (www.pnotepad.org) and use the built-in regular expression functionality in the Search/Replace.

If all dates in the document need to be replaced with the current date, you can use this search pattern:

\d{4}-\d{2}-\d{2}

Enter the current date in the replace field and all instances of a date in the format of YYYY-MM-DD will be replaced with the current date.

If there are dates that should not be changed, in addition to those that should, then you want to use a more specific search pattern:

e.g.,

Search Pattern
(<DOC_REC_DT_DC Attribute="Y"><!\[CDATA\[)\d{4}-\d{2}-\d{2}

Replace Pattern
\1<current date>    

(replace "<current date>" with the actual date value)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question