China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 08:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How can this kind of XML text manipulation be done with a script View 985 Replies 13
Original Poster Posted 2008-07-24 16:12 ·  中国 四川 成都 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
I want to work with an IIS configuration file. For example, some of the content in the text is as follows. These are 2 sites, test1.com and test2.com, both belonging to the same application pool AppPool #10. I want to use a script to reassign the 2 sites below so that each site corresponds to one application pool, for example making site test1.com go to application pool test1.com #10; and putting site test2.om into application pool test2.com #10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~begin
<IIsWebServer Location ="/LM/W3SVC/1692685952"
AuthFlags="0"
ServerAutoStart="TRUE"
ServerBindings=":80:test1.com"
ServerComment="test1.com"
>
</IIsWebServer>
<IIsFilters Location ="/LM/W3SVC/1692685952/filters"
>
</IIsFilters>
<IIsWebVirtualDir Location ="/LM/W3SVC/1692685952/root"
AccessFlags="AccessRead"
AppFriendlyName="Default Application"
AppIsolated="2"
AppPoolId="AppPool #10"
AppRoot="/LM/W3SVC/1692685952/Root"
>
</IIsWebVirtualDir>





<IIsWebServer Location ="/LM/W3SVC/1796746353"
AuthFlags="0"
ServerAutoStart="TRUE"
ServerBindings=":80:test2.com"
ServerComment="test2.com"
>
</IIsWebServer>
<IIsFilters Location ="/LM/W3SVC/1796746353/filters"

>
</IIsFilters>
<IIsWebVirtualDir Location ="/LM/W3SVC/1796746353/root"
AccessFlags="AccessRead"
AppFriendlyName="Default Application"
AppIsolated="2"
AppPoolId="AppPool #10"
AppRoot="/LM/W3SVC/1796746353/Root"
AuthFlags="AuthAnonymous | AuthNTLM"
DirBrowseFlags="DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate |

EnableDefaultDoc"
Path="E:\dbbackup"
>
</IIsWebVirtualDir>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~end


The result after doing this is as follows
<IIsWebServer Location ="/LM/W3SVC/1692685952"
AuthFlags="0"
ServerAutoStart="TRUE"
ServerBindings=":80:test1.com"
ServerComment="test1.com"
>
</IIsWebServer>
<IIsFilters Location ="/LM/W3SVC/1692685952/filters"
>
</IIsFilters>
<IIsWebVirtualDir Location ="/LM/W3SVC/1692685952/root"
AccessFlags="AccessRead"
AppFriendlyName="Default Application"
AppIsolated="2"
AppPoolId="test1.com #10"
AppRoot="/LM/W3SVC/1692685952/Root"
>
</IIsWebVirtualDir>





<IIsWebServer Location ="/LM/W3SVC/1796746353"
AuthFlags="0"
ServerAutoStart="TRUE"
ServerBindings=":80:test2.com"
ServerComment="test2.com"
>
</IIsWebServer>
<IIsFilters Location ="/LM/W3SVC/1796746353/filters"

>
</IIsFilters>
<IIsWebVirtualDir Location ="/LM/W3SVC/1796746353/root"
AccessFlags="AccessRead"
AppFriendlyName="Default Application"
AppIsolated="2"
AppPoolId="test2.com #10"
AppRoot="/LM/W3SVC/1796746353/Root"
AuthFlags="AuthAnonymous | AuthNTLM"
DirBrowseFlags="DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate |

EnableDefaultDoc"
Path="E:\dbbackup"
>
</IIsWebVirtualDir>

[ Last edited by lfzzj on 2008-7-25 at 11:43 AM ]
Floor 2 Posted 2008-07-24 16:55 ·  中国 四川 成都 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
Actually the main problem is that I don't know how to extract the names of 2 or more sites that all belong to AppPool #10, for example extracting the names test1.com and test2.com, etc.
Also, I still don't know how to replace AppPool #10 with test1.com #10 and test2.com #10, etc.
Floor 3 Posted 2008-07-24 18:25 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Like this:

@echo off&setlocal enabledelayedexpansion
for /f "tokens=2 delims=:" %%i in ('findstr /n .* iis.ini') do (
set "str=%%i"
if "!str:ServerComment=!" neq "%%i" call :lp
if not defined flag (
set "flag=a"&echo %%i>iis.ini
) else (
if "!str:PoolId=!" neq "%%i" (
echo AppPool="!var! ^#10">>iis.ini
) else (
echo.%%i>>iis.ini
)))
start iis.ini&goto :eof
:lp
for /f "tokens=2 delims==" %%i in ("%str%") do set "var=%%~i"


[ Last edited by bat-zw on 2008-7-24 at 06:32 PM ]
批处理之家新域名:www.bathome.net
Floor 4 Posted 2008-07-24 19:20 ·  中国 四川 成都 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
Floor 5 Posted 2008-07-24 20:48 ·  中国 四川 成都 成华区 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
Could you all please help solve this
Floor 6 Posted 2008-07-24 22:36 ·  中国 湖北 武汉 联通
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
What you need is xmlStarlet

http://xmlstar.sourceforge.net/
Floor 7 Posted 2008-07-24 23:01 ·  中国 四川 成都 成华区 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
Could you please give a bit more of an idea, boss
Floor 8 Posted 2008-07-25 00:59 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
The code I gave, shouldn't the OP be able to achieve it by modifying it a bit?
批处理之家新域名:www.bathome.net
Floor 9 Posted 2008-07-25 09:55 ·  中国 四川 成都 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
I got somewhat familiar with xmlStarlet, but I still can't extract all the sites that belong to the AppPool #10 application pool, for example extracting test1.com and test2.com
Floor 10 Posted 2008-07-25 17:26 ·  中国 四川 成都 电信
初级用户
★★
Credits 159
Posts 56
Joined 2006-09-15 10:31
19-year member
UID 62663
Status Offline
If no expert can answer, then I'll just have to try using vbs
Floor 11 Posted 2008-07-25 18:45 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
VBS is great... for this kind of operation just use VBS... fast and accurate
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 12 Posted 2008-07-25 23:41 ·  中国 北京 鹏博士BGP
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Doesn't IIS have several corresponding VBS scripts for operating and controlling IIS status?
For example, operations like adding a site.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 13 Posted 2008-07-26 09:52 ·  中国 福建 福州 连江县 联通
高级用户
★★
Credits 581
Posts 277
Joined 2006-12-23 05:10
19-year member
UID 74328
Gender Male
Status Offline
Originally posted by lxmxn at 2008-7-24 22:36:
What you need is xmlStarlet

http://xmlstar.sourceforge.net/


Moderator, if you have time, could you write a Chinese tutorial for xmlStarlet?

It would be best to give a few examples for reference
Floor 14 Posted 2008-08-01 09:31 ·  中国 北京 光环新网
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Search Baidu for xmlStarlet

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Forum Jump: