I am trying to extract a element value from a xml output string using batch. Have used below code , it is working fine with fomatted xml lines and not on single xml string. For e.g:
Formatted xml:*
<?xml version="1.0" encoding="utf-16"?>
<DEVICE>
<AGENT>
<VERSION>2.0.0.2</VERSION>
<CONNECTION>
<LOCATION>US_NY</LOCATION>
<SERVERIP>
127.0.0.1
</SERVERIP>
<TCPPORT>
5656
</TCPPORT>
<POLLINTERVAL>
5
</POLLINTERVAL>
</CONNECTION>
</AGENT>
</DEVICE>
Batch script used:
@echo off
setlocal enableextensions EnableDelayedExpansion
set input="test.xml"
for /F "tokens=2 delims=<>" %%I in ('type %input% ^|find "</password>"') do (
set pwd=%%I echo !pwd! )
How to extract value from any unformatted xml string?