[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdepim/kresources/groupwise/soap
From:       Cornelius Schumacher <schumacher () kde ! org>
Date:       2004-09-30 9:24:01
Message-ID: 20040930092401.8F3459BAF () office ! kde ! org
[Download RAW message or body]

CVS commit by cschumac: 

Handle multi-line files.


  M +32 -13    extractxml.pl   1.2


--- kdepim/kresources/groupwise/soap/extractxml.pl  #1.1:1.2
@@ -18,21 +18,40 @@
 
 while ( <IN> ) {
-  if ( $_ =~ /^(\<\?xml.*\<\/SOAP-ENV:Envelope\>)/ ) {
-    $xml = $1;
+  if ( $xml ) {
+    if ( $_ =~ /(.*\<\/SOAP-ENV:Envelope\>)/ ) {
+      printXml( $xml . $1 );
+      $xml = "";
+    } else {
+      $xml .= $_;
+    }
+  } elsif ( $_ =~ /^(\<\?xml.*\?>)(.*)$/ ) {
+    $xml = $1 . $2;
 
-    $out = "$in.$count.xml";
+    if ( $xml =~ /(.*\<\/SOAP-ENV:Envelope\>)/ ) { 
+      printXml( $1 );
+      $xml = "";
+      
+    }
+  }
+}
 
-    print "Out: $out\n";
+sub printXml()
+{
+  $xml = shift;
 
-    if ( !open OUT, ">$out" ) {
-      print STDERR "Unable to open file '$out'.\n";
-    } else {
-      print OUT $xml;
-      close OUT;
-    }
-    
-    $count += 1;
+  $xml =~ s/\n//g;
+  $xml =~ s/\r//g;
+
+  $out = "$in.$count.xml";
+
+  print "Out: $out\n";
+
+  if ( !open OUT, ">$out" ) {
+    print STDERR "Unable to open file '$out'.\n";
   } else {
-#    print "XXXX: $_";
+    print OUT $xml;
+    close OUT;
   }
+
+  $count += 1;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic