xml 파일의 형식을 다음과 같이 구문 분석하고 있습니다.
<ResourcePicture Name="a.jpg">
<GeneratedPicture Name="b.jpg"/>
<GeneratedPicture Name="c.jpg"/>
</ResourcePicture>
그림의 각 이름을 인쇄 할 수 있지만 안에있는 if 문으로 무언가를 확인하고 싶습니다. 그러나 "<은 (는) 현재 예기치 않은 오류입니다."라는 오류 메시지가 표시됩니다. 그러나 if 문을 제거하면 잘 작동합니다. 그래서 나는 무엇을 놓치고 있습니까? 미리 감사드립니다.
set "xmlFile=pictures.xml"
REM split xml file into lines
for /f "tokens=* skip=2" %%a in (%xmlFile%) do (
REM %%a contais a string like <ResourcePicture Name="a.jpg">
set "currnetLine=%%a"
set "currnetLine=!currnetLine:"=+!"
set counter=0
for /f "delims=+ tokens=2" %%c in ("!currnetLine!") do (
REM %%c contains the picture name like a.jpg
set /a counter=counter+1
REM CHECKING SOMETHING
if not %counter%==1 ( echo abc )
echo %%c
)
)
지연된 확장 이 필요 합니다 (스크립트의 논리가 원하는 것을 달성하는지 모르겠지만 이와 같이 오류가 없습니다) :
@echo off
set "xmlFile=pictures.xml"
REM split xml file into lines
setlocal enableDelayedExpansion
for /f "tokens=* skip=2" %%a in (%xmlFile%) do (
REM %%a contais a string like <ResourcePicture Name="a.jpg">
set "currnetLine=%%a"
set "currnetLine=!currnetLine:"=+!"
set counter=0
for /f "delims=+ tokens=2" %%c in ("!currnetLine!") do (
REM %%c contains the picture name like a.jpg
set /a counter=counter+1
REM CHECKING SOMETHING
if not !counter! == 1 ( echo abc )
echo %%c
)
)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다