中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-09 09:12
47,811 topics / 349,895 posts / today 0 new / 48,253 members
DOS批处理 & 脚本技术(批处理室) » [Help] How can this kind of XML text manipulation be done with a script
Printable Version  987 / 13
Floor1 lfzzj Posted 2008-07-24 16:12
初级用户 Posts 56 Credits 159
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 ]
Floor2 lfzzj Posted 2008-07-24 16:55
初级用户 Posts 56 Credits 159
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.
Floor3 bat-zw Posted 2008-07-24 18:25
金牌会员 Posts 1,276 Credits 3,105
Like this:


[ Last edited by bat-zw on 2008-7-24 at 06:32 PM ]
Floor4 lfzzj Posted 2008-07-24 19:20
初级用户 Posts 56 Credits 159
Floor5 lfzzj Posted 2008-07-24 20:48
初级用户 Posts 56 Credits 159
Could you all please help solve this
Floor6 lxmxn Posted 2008-07-24 22:36
版主 Posts 4,938 Credits 11,386
What you need is xmlStarlet

http://xmlstar.sourceforge.net/
Floor7 lfzzj Posted 2008-07-24 23:01
初级用户 Posts 56 Credits 159
Could you please give a bit more of an idea, boss
Floor8 bat-zw Posted 2008-07-25 00:59
金牌会员 Posts 1,276 Credits 3,105
The code I gave, shouldn't the OP be able to achieve it by modifying it a bit?
Floor9 lfzzj Posted 2008-07-25 09:55
初级用户 Posts 56 Credits 159
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
Floor10 lfzzj Posted 2008-07-25 17:26
初级用户 Posts 56 Credits 159
If no expert can answer, then I'll just have to try using vbs
Floor11 slore Posted 2008-07-25 18:45
铂金会员 Posts 2,478 Credits 5,212
VBS is great... for this kind of operation just use VBS... fast and accurate
Floor12 yishanju Posted 2008-07-25 23:41
银牌会员 Posts 1,357 Credits 1,488
Doesn't IIS have several corresponding VBS scripts for operating and controlling IIS status?
For example, operations like adding a site.
Floor13 suntb Posted 2008-07-26 09:52
高级用户 Posts 277 Credits 581
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
Floor14 yishanju Posted 2008-08-01 09:31
银牌会员 Posts 1,357 Credits 1,488
Search Baidu for xmlStarlet
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023