1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<wpkg><package id="acrobat8" name="Acrobat Reader 8.1.2" revision="812" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Adobe Reader 8.1.2 - Deutsch"/>
<install cmd="msiexec /q /i "%SOFTWARE%\pkg\adobe\AcroRead.msi" allusers=1">
<exit code="0"/>
</install>
<remove cmd="MsiExec.exe /q /x{AC76BA86-7AD7-1031-7B44-A70500000002}"/>
<upgrade cmd="msiexec /q /i "%SOFTWARE%\pkg\adobe\AcroRead.msi" allusers=1">
<exit code="0"/>
<exit code="3010"/>
</upgrade>
</package>
<package id="ReportViewer" name="Microsoft Report Viewer Redistributable 2008" revision="2" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Microsoft Report Viewer Redistributable 2008"/>
<install cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /q">
<exit code="0"/>
</install>
<remove cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /qu"/>
</package>
<package id="pdfcreator" name="PDFCreator" revision="091" priority="0" reboot="false">
<check type="uninstall" condition="exists" path="PDFCreator"/>
<install cmd="msiexec /qb /i "%SOFTWARE%\pkg\pdfcreator\PDFCreator-0_9_1_AFPLGhostscript_32bit.msi""/>
<install cmd="rundll32 printui.dll,PrintUIEntry /q /ga pdfcreator"/>
<remove cmd="MsiExec.exe /q /x{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}"/>
<upgrade cmd=""/>
</package>
....
1
2
3
4
5
6
7
<package id="ReportViewer" name="Microsoft Report Viewer Redistributable 2008" revision="2" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Microsoft Report Viewer Redistributable 2008"/>
<install cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /q">
<exit code="0"/>
</install>
<remove cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /qu"/>
</package>
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl -w open(INFILE, "</test.xml") or die "Can't open input.txt: $!"; open(OUTFILE, ">output.txt") or die "Can't open output.txt: $!"; my $string = do { local $/; <INFILE> }; my $text = $string; #print $string; $text =~ s/(<package id="ReportViewer" name="M.*<\/package>)//ms; #print $text; print $&; print OUTFILE $text; close INFILE; close OUTFILE;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
use 5.010; use strict; use warnings; use XML::LibXML; my $doc = XML::LibXML->load_xml(IO => \*DATA); my ($pkg) = $doc->findnodes(q{/wpkg/package[@id = 'ReportViewer']}); if ($pkg) { say $pkg->toString; } else { die 'No such node'; } __DATA__ <wpkg> <package id="acrobat8" name="Acrobat Reader 8.1.2" revision="812" reboot="false" priority="10"> <check type="uninstall" condition="exists" path="Adobe Reader 8.1.2 - Deutsch"/> <install cmd="msiexec /q /i "%SOFTWARE%\pkg\adobe\AcroRead.msi" allusers=1"> <exit code="0"/> </install> <remove cmd="MsiExec.exe /q /x{AC76BA86-7AD7-1031-7B44-A70500000002}"/> <upgrade cmd="msiexec /q /i "%SOFTWARE%\pkg\adobe\AcroRead.msi" allusers=1"> <exit code="0"/> <exit code="3010"/> </upgrade> </package> <package id="ReportViewer" name="Microsoft Report Viewer Redistributable 2008" revision="2" reboot="false" priority="10"> <check type="uninstall" condition="exists" path="Microsoft Report Viewer Redistributable 2008"/> <install cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /q"> <exit code="0"/> </install> <remove cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /qu"/> </package> <package id="pdfcreator" name="PDFCreator" revision="091" priority="0" reboot="false"> <check type="uninstall" condition="exists" path="PDFCreator"/> <install cmd="msiexec /qb /i "%SOFTWARE%\pkg\pdfcreator\PDFCreator-0_9_1_AFPLGhostscript_32bit.msi""/> <install cmd="rundll32 printui.dll,PrintUIEntry /q /ga pdfcreator"/> <remove cmd="MsiExec.exe /q /x{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}"/> <upgrade cmd=""/> </package> </wpkg>