Thread suchen & ersetzen multiline (3 answers)
Opened by micneu at 2011-04-05 14:32

murphy
 2011-04-05 18:45
#147401 #147401
User since
2004-07-19
1776 Artikel
HausmeisterIn
[Homepage]
user image
Sehr bequem zu benutzen ist zum Beispiel CPAN:XML::LibXML:
Code (perl): (dl )
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 &quot;%SOFTWARE%\pkg\adobe\AcroRead.msi&quot; allusers=1">
      <exit code="0"/>
    </install>
    <remove cmd="MsiExec.exe /q /x{AC76BA86-7AD7-1031-7B44-A70500000002}"/>
    <upgrade cmd="msiexec /q /i &quot;%SOFTWARE%\pkg\adobe\AcroRead.msi&quot; 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 &quot;%SOFTWARE%\pkg\pdfcreator\PDFCreator-0_9_1_AFPLGhostscript_32bit.msi&quot;"/>
    <install cmd="rundll32 printui.dll,PrintUIEntry /q /ga pdfcreator"/>
    <remove cmd="MsiExec.exe /q /x{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}"/>
    <upgrade cmd=""/>
  </package>
</wpkg>
When C++ is your hammer, every problem looks like your thumb.

View full thread suchen & ersetzen multiline