OT, but need help, please - RegEx, FSO to read XML and replace values??

E

Ed from AZ

Okay - it's not specifically Word VBA, except that's what I'm familiar
with for a starting point.

I need to iterate through a folder of XML files, find a couple of
tags, and replace the values. That sounds really simple, but the only
way I can think of to do it in my current limited capabilities is to
use FSO to grab each file and read the contents, write all that into a
Word doc, use Word's wildcard Find/Replace, then grab all the text and
write it back into the XML file.

I'm thinking it would be much easier once I read each file's contents
into a string to just work within the string. I think maybe I
remember doing that once using Regular Expressions to find the
string?? But I hang up when I try to think of how to extract the
value from what I've found.

So if in the string, I have:
<TAG1>HI</TAG1>
and I need to replace HI with HELLO,
can I do all that within the string while it's in memory without
having to write it into a doc, play with it, and write it back out?

Ed
 
D

David Sisson

So if in the string, I have:
<TAG1>HI</TAG1>
and I need to replace HI with HELLO,
can I do all that within the string while it's in memory without

Use the Replace Function.

Syntax

Replace(expression, find, replace[, start[, count[, compare]]])

Inside the FSO loop, read each line and apply the Replace function to
the string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top