A batch file to extract the value of XML tag

November 22, 2011 at 09:07:24
Specs: Windows XP
How do I extract the value of a specific XML tag (DATA tag in the following code) from .XML file and write it into a .txt file ?

My file looks like this :

<TABLE>
Table 30

<ROW>
Multiple Rows

<DATA>
Capital gains are the key ingredient of income disparity in the US-- and the force behind the winner takes all mantra of our economic system. If you want even out earning power in the U.S, you have to raise the 15% capital gains tax.
</DATA>

</ROW>

</TABLE>

So that the output should be like this:

Capital gains are the key ingredient of income disparity in the US-- and the force behind the winner takes all mantra of our economic system. If you want even out earning power in the U.S, you have to raise the 15% capital gains tax.


See More: A batch file to extract the value of XML tag

Report •

#1
November 22, 2011 at 16:26:04
If the xml file always is in the same format as it is above, for example always 7 lines from <TABLE> down to <DATA>, then the script below will work.

for /f "tokens=* delims=* skip=7" %%A in (xml.xml) do (if /I "%%A"=="</DATA>" (pause) & (EXIT) else (echo %%A>>xml.txt))


Report •
Related Solutions


Ask Question