xml からデータを抽出し、それをバッチ ファイル変数に渡すのに助けが必要です...
必要なデータを取得できず、それをバッチ変数に渡すことができないようです。
TAGID から "AH0417" を抽出する必要があります....キャッチ 22 - このファイルは TAGID / PHASEID / BOXID を変更します
したがって、それらが同じになることはめったにありません... delimsを次のように変更すると、特定のファイルを1つ抽出できます
for /f "tokens=7,18-21* delims=^<![CDT[^>]] " %%a in ('find /I /N "<PHASEID>"^<Config.xml') do (
set a=%%a
)
echo %a%
それは私が delims や tokens のすべての異なる方法で今いる場所です。skip=3 を使用すると、予期しない原因になります]
どんな助けでも素晴らしいでしょう、私はこれを一週間ずっと働いていて、助けを求めてオンラインで投稿しましたが、まだ返信がありません...これが難しいのか不可能なのかはわかりませんが、可能性はわかっています。これを見ている右の目セット笑。助けてくれてありがとう...
<?xml version="1.0" encoding="UTF-16"?>
-<root>-<CONFIG>-<TAGID>
<![CDATA[AH0417]]>
</TAGID>-<DATETIMESTAMP>
<![CDATA[9/18/2012 4:59:08 PM]]>
</DATETIMESTAMP>-<SYSTYPE>
<![CDATA[PTWS]]>
</SYSTYPE>-<PHASEID>
<![CDATA[WJFKB02229001]]>
</PHASEID>-<BOXID>
<![CDATA[D]]>
</BOXID></CONFIG></root>
トークンと delim でさまざまな組み合わせを使用しましたが、実際のデータではなく、結果として空白の %PhaseID% を取得するか、数値 "2" を取得します。これは私がやろうとしていることです...
REM ***************************************(PTLS)********************************************************
:PTLSsetup
sET sOURCE=%HOMEDRIVE%\ULLSA\PHASE\PTLS\DATA\XML
rem Extract XML to Batch
rem for /f "skip=3 tokens=* delims=[" %%G IN (C:\Ullsa\phase\ptls\data\xml\Config.xml) Do (
rem Set Serial=%%G
rem Set PhaseID=%%H
rem Set BoxID=%%I
rem )
rem echo %serial%
rem echo %PhaseID%
rem echo %BoxID%
これは完全なスクリプトです.....
mode con:cols=70 lines=25
rem Created by (ROBERT)
color 0c
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set day=%%b
set today=%day%-%month%-%year%
echo %today%
rem **************************(LOG CREATION)************************************************
md c:\zMigrate\Backup
set currentd=C:\zMigrate\Backup
ping -n 6 127.0.0.1 >nul
CLS
echo.
set D=%date% %time%
set T=%time%
echo ****************************************** >>%currentd%\%today%.TXT
echo %Date% ---------------------^> Log Created on %computername% >>%currentd%\%today%.TXT
echo ****************************************** >>%currentd%\%today%.TXT
echo LOG CREATED IN %currentd%\%today%.TXT
echo LOG CREATED FROM %currentd% >>%currentd%\%today%.TXT
echo ****************************************** >>%currentd%\%today%.TXT
cls
rem ******************************(MENU)****************************************************
:Menu
echo *******************
IF EXIST "C:\ULLSA\PHASE\PTLS" ECHO PTLS IS INSTALLED
IF ERRORLEVEL 1 ECHO PTLS NOT INSTALLED
IF EXIST "C:\ULLSA\PHASE\PTWS" ECHO PTWS IS INSTALLED
IF ERRORLEVEL 1 ECHO PTWS NOT INSTALLED
echo *******************
IF EXIST "C:\ULLSA\PHASE\PTLS" ECHO %T% PTLS IS INSTALLED >>%currentd%\%today%.TXT
IF ERRORLEVEL 1 ECHO %T% PTLS NOT INSTALLED >>%currentd%\%today%.TXT
IF EXIST "C:\ULLSA\PHASE\PTWS" ECHO %T% PTWS IS INSTALLED >>%currentd%\%today%.TXT
IF ERRORLEVEL 1 ECHO %T% PTWS NOT INSTALLED >>%currentd%\%today%.TXT
echo.
echo.
echo.
echo.
echo.
echo WHAT TYPE WORKSTATION IS THIS?
echo.
echo *NOTE* THIS UTILITY WILL PHASE MIGRATION FILES!!!
echo.
echo.
ECHO 1: PTLS (Phase Team Leader Station)
echo.
ECHO 2: PTWS (Phase Team Workers Station)
echo.
ECHO 0: Leave Program
ECHO.
SET /p choice=Enter a number [0,1,2]:
if /i [%choice%]==[0] endlocal&goto end
if [%choice%]==[] goto Menu
if [%choice%]==[1] goto PTLS
if [%choice%]==[2] goto PTWS
ECHO Unrecognized entry. Please try again.
goto Menu
REM ***************************************(TYPE CHECK)**************************************************
:PTLS
cls
ECHO *************************
echo ***Starting PTLS Check***
ECHO *************************
echo %T% ***Starting PTLS Check*** >>%currentd%\%today%.TXT
PING -n 3 127.0.0.1>nul
CLS
set PTLSDATA="C:\ULLSA\PHASE\PTLS\DATA\XML"
if exist %ptlsdata%\config.xml goto PTLSsetup
if errorlevel 1 goto PTLSFail
:PTLSFAIL
cls
echo ********************************************************
echo **PTLS XML DOES NOT EXIST, ENSURE PTLS IS INSTALLED...**
echo ********************************************************
echo %T% **PTLS XML DOES NOT EXIST, ENSURE PTLS IS INSTALLED...** >>%currentd%\%today%.TXT
ping -n 6 127.0.0.1>nul
goto Menu
:PTWS
cls
ECHO *************************
echo ***Starting PTWS Check***
ECHO *************************
echo %T% ***Starting PTWS Check*** >>%currentd%\%today%.TXT
PING -n 3 127.0.0.1>nul
CLS
set PTWSDATA="C:\ULLSA\PHASE\PTwS\DATA\XML"
if exist %ptwsdata%\config.xml goto PTWSsetup
if errorlevel 1 goto PTWSFail
:PTWSFAIL
cls
echo ********************************************************
echo **PTWS XML DOES NOT EXIST, ENSURE PTWS IS INSTALLED...**
echo ********************************************************
echo %T% PTWS XML DOES NOT EXIST, ENSURE PTWS IS INSTALLED. >>%currentd%\%today%.TXT
ping -n 6 127.0.0.1>nul
goto Menu
REM ***************************************(PTLS)********************************************************
:PTLSsetup
sET sOURCE=%HOMEDRIVE%\ULLSA\PHASE\PTLS\DATA\XML
rem Extract XML to Batch
rem for /f "skip=3 tokens=* delims=[" %%G IN (C:\Ullsa\phase\ptls\data\xml\Config.xml) Do (
rem Set Serial=%%G
rem Set PhaseID=%%H
rem Set BoxID=%%I
rem )
rem echo %serial%
rem echo %PhaseID%
rem echo %BoxID%
echo **********************************
echo ***Setting up PhaseID and BoxID***
echo **********************************
echo %T% ***Setting up PhaseID and BoxID*** >>%currentd%\%today%.TXT
ping -n 4 127.0.0.1>nul
CLS
rem extract xml data to phaseid and boxid
Set PhaseID=PhaseID
Set BoxID=BoxID
set Pbackup=%HOMEDRIVE%\Backup\%PhaseID%
set Bbackup=%HOMEDRIVE%\Backup\%PhaseID%\%BoxID%
Set Backup=%HOMEDRIVE%\Backup\%PhaseID%\%BoxID%
ping -n 4 127.0.0.1>nul
goto PTLSBackup
:PTLSBackup
if exist %backup% goto ptlsxfr
if errorlevel 1 goto ptlsmd
:ptlsmd
MD %backup% >>%currentd%\%today%.TXT
echo %T% Creating Phase Folder >>%currentd%\%today%.TXT
echo %T% Creating Box Folder >>%currentd%\%today%.TXT
echo Creating Destination
ping -n 6 127.0.0.1>nul
if exist %Bbackup% goto ptlsxfr
if errorlevel 1 echo %T% CAN^'T CREATE DESTINATION >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
CLS
goto menu
:ptlsxfr
echo ****************************
echo ***Created Destination***
echo ****************************
echo %T% ***Created Destination*** >>%currentd%\%today%.TXT
PING -n 3 127.0.0.1>nul
CLS
echo ****************************
echo ***Starting PTLS Transfer***
echo ****************************
echo %T% ***Starting PTLS Transfer*** >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
CLS
echo.
cacls "%sOURCE%" /T /E >>%currentd%\%today%.TXT
cacls "%backup%" /T /E >>%currentd%\%today%.TXT
CLS
echo Transfering Phase: %phaseID% Box: %BoxID%
echo %T% Transfering Phase: %phaseID% Box: %BoxID% >>%currentd%\%today%.TXT
xcopy "%sOURCE%\*" "%backup%\" /Y /E /H /V /G >>%currentd%\%today%.TXT
CLS
ECHO Transfer Complete
ECHO %T% Transfer Complete >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
EXIT
REM ***************************************(PTWS)********************************************************
:PTWSsetup
rem Extract XML to Batch
rem place code or cmd to call to vbs
echo **********************************
echo ***Setting up PhaseID and BoxID***
echo **********************************
echo %T% ***Setting up PhaseID and BoxID*** >>%currentd%\%today%.TXT
ping -n 4 127.0.0.1>nul
CLS
rem extract xml data to phaseid and boxid
Set PhaseID=PhaseID
Set BoxID=BoxID
set Pbackup=%HOMEDRIVE%\Backup\%PhaseID%
set Bbackup=%HOMEDRIVE%\Backup\%PhaseID%\%BoxID%
Set Backup=%HOMEDRIVE%\Backup\%PhaseID%\%BoxID%
sET sOURCE=%HOMEDRIVE%\ULLSA\PHASE\PTWS\DATA\XML
goto PTWSBackup
:PTWSBackup
if exist %backup% goto ptWsxfr >>%currentd%\%today%.TXT
if errorlevel 1 goto ptWsmd >>%currentd%\%today%.TXT
:ptWsmd
MD %backup% >>%currentd%\%today%.TXT
echo %T% Creating Phase Folder >>%currentd%\%today%.TXT
echo %T% Creating Box Folder >>%currentd%\%today%.TXT
echo Creating Destination
ping -n 6 127.0.0.1>nul
if exist %Bbackup% goto ptWsxfr
if errorlevel 1 echo %T% CAN^'T CREATE DESTINATION >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
goto menu
:ptWsxfr
echo ****************************
echo ***Created Destination***
echo ****************************
echo %T% ***Created Destination*** >>%currentd%\%today%.TXT
PING -n 2 127.0.0.1>nul
cls
echo ****************************
echo ***Starting PTWS Transfer***
echo ****************************
echo %T% ***Starting PTWS Transfer*** >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
CLS
echo.
cacls "%sOURCE%" /T /E >>%currentd%\%today%.TXT
cacls "%backup%" /T /E >>%currentd%\%today%.TXT
CLS
echo Transfering Phase: %phaseID% Box: %BoxID%
echo %T% Transfering Phase: %phaseID% Box: %BoxID% >>%currentd%\%today%.TXT
xcopy "%sOURCE%\*" "%backup%\" /Y /E /H /V /G >>%currentd%\%today%.TXT
ECHO Transfer Complete
ECHO %T% Transfer Complete >>%currentd%\%today%.TXT
ping -n 3 127.0.0.1>nul
EXIT