Forum Discussion

Oz_Ayd_69699's avatar
Oz_Ayd_69699
Icon for Nimbostratus rankNimbostratus
Mar 07, 2007

regexp and xml

How do you extract the operation name from a SOAP request (body) using regexp?

 

In the following request, how do you extract CalcSalary from the XML using regexp?

 

 

----- Sample Request Body ------

 

 

 

 

123

 

 

 

 

 

Cheers

 

Oz

1 Reply

  • Give this a shot:

    when HTTP_REQUEST {
      set content "  xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" 
      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">123"
      set matches [regexp -inline {[\r\n ]*<(\w+)} $content]
      if { [llength $matches] > 1 } {
        $fullMatch = [lindex $matches 0]
        $methodName = [lindex $matches 1]
      }
    }

    Not foolproof but it should work for the example you've given.

    -Joe