2

I will change my links to lower case by using vbs. The xml files have different structures.

In every file I would like to make the value of attribute src to lower cases. Can someone show me how to change the attribute values of src by using vbs?

My problem is how to read the xml file, find the value and write it back to the xml file.

This example shows what I want to do.

Source Example XML

<body>
<title>example</title>
 <p>this is <xref src="TEST.xml#548L521">test</xref> file</p>
 <table>
  <tr>
    <td><p>this is <xref src="StAckOverflow.xml">test</xref> file</p></td>
    <td><p>this is test file</p></td>
  </tr>
 </table>
</body>

Result Example XML

<body>
<title>example</title>
 <p>this is <xref src="test.xml#548l21">test</xref> file</p>
 <table>
  <tr>
    <td><p>this is <xref src="stackoverflow.xml">test</xref> file</p></td>
    <td><p>this is test file</p></td>
  </tr>
 </table>
</body>
Julian E.
  • 4,687
  • 6
  • 32
  • 49
Olli
  • 89
  • 7

1 Answers1

1

The file you want to change is not in XML format but is HTML. The solution for XML would be different, for HTML the simplest thing to do is open the html (text) file, do a search and replace of the text to be replaced and save the result. If the text to search for is always the same use a simple replace, otherwise use a regular expression.

Using regular expressions to seach and replace html is not ideal but since in this case it is a simple pattern I would go for that solution.

Your text to search would be <xref src="StAckOverflow.xml"> and the variable part of it would become your regular expression.

We are not supposed to write your code, so I'll just point you to some pages to start with.

Read and write into a file using VBScript for opening and saving a modified textfile and

https://technet.microsoft.com/en-us/library/2008.05.heyscriptingguy.aspx

for replacing using a regular expression.

Publish what you tried so that we can help you better.

Community
  • 1
  • 1
peter
  • 41,770
  • 5
  • 64
  • 108