如何从节点批处理文件中获取值或替换值

时间:2013-10-11 08:01:16

标签: batch-file

请看这个例子

<Invoice>
            <InvoiceNo>FR 2013A/6298</InvoiceNo>
<DocumentStatus>
            <InvoiceStatus>N</InvoiceStatus>
<InvoiceStatusDate></InvoiceStatusDate>
<SourceID>Admin</SourceID>
<SourceBilling>P</SourceBilling>
</DocumentStatus>
            <Hash>gjzW4RgCJ+KSv5dG0HwQXaW6asAbHW+XyAPfnUm6eBZkOtoUr7I733z6RARRc+QMH9XGxFGZ5qe6vpoC524z9Km3mDmhe83/YZCcIeIQsfo9cFBGGc8cGos4a6PlrefBXsmMT+Sc8gl8RavBf2Zc7/wHARASVnjx8Yf2l9ZGRC8=</Hash>
            <HashControl>1</HashControl>
            <Period>9</Period>
            <InvoiceDate>2013-09-02</InvoiceDate>
            <InvoiceType>VD</InvoiceType>
            <SelfBillingIndicator>0</SelfBillingIndicator>
<SourceID>Admin</SourceID>
            <SystemEntryDate>2013-09-02T10:13:33</SystemEntryDate>
</Invoice>

我需要将<InvoiceStatusDate></InvoiceStatusDate>放在<SystemEntryDate></SystemEntryDate>内的同一日期,但问题是,在每个<Invoice> <SystemEntryDate></SystemEntryDate>的值都不同,我需要将每个<SystemEntryDate>的结果与每个<InvoiceStatusDate>对应,所以我试试这个

@echo off
setlocal EnableDelayedExpansion

set anotherVariable=New value

(for /F "delims=" %%a in (setembro.xml) do (

   set "line=%%a"
   set "!line:InvoiceStatusDate>=! == !line:SystemEntryDate>=!"
   set "newLine=!line:InvoiceStatusDate>=!"
   if "!newLine!" neq "!line!" (
      set "newLine=!line!"
      echo !newLine!
      set "newLine == %SystemEntryDate%"
      echo !newLine!
   )  
   @echo !newLine!
)) > 7.xml

但不起作用

0 个答案:

没有答案