0
votes

I am new to Jmeter and I am trying to use Regular Expression Extractor to extract a single value from XML response of one of the HTTP requests. I am aware of the expression I need to use to extract the value but I don't have an idea of how to escape or ignore or include the new line. Below is the small part of my XML response and regular expression extractor that I am using to extract the value between "name" child/sub node:

 <com.mfs.model.connector.ConnectorBrowseInfo>
          <type>css</type>
          <name>Cascading Style Server</name>
          <typeGroup>css</typeGroup>

Regular Expression Extractor configuration:

Name of created variable: connectorNameVar
Regular Expression Extractor: <com\.msf\.model\.connector\.ConnectorBrowseInfo>\n          <type>(.*?)<\/type>\n          <name>(.*?)<\/name>\n
Template: $2$
Match No.: 0
Default Value: NotFound

This expression return "NotFound" value instead of taking the value 'Cascading Style Server" Can anyone please help me figure out what I need to add or remove or change in my expression?

Acceptance Criteria: The name needs to be extracted from '<com.mfs.model.connector.ConnectorBrowseInfo>' this node.

1
Your regex worked for me just by replacing <com\.boomi with <com\.mfs in your Regular Expression Extractorararar
In same XML response, I have following node, subnode and child node: <com.msf.model.platform.common.Container> <containerId>abhc-123abh-Fgh%908-5rmka</containerId> <hostName>EQ AMC</hostName> <name>kkp_test</name> When I use same regex as mentioned above it won't take any valueNikita
Well, your regex is written to extract the name value from this node <com.mfs.model.connector.ConnectorBrowseInfo> which is the node you specified in your question not this one <com.msf.model.platform.common.Container>.ararar
Right, that was my initial question - I am using the same regex in my apache-jmeter-4.0 and it is taking Default Value "NotFound" so this regex is not working correctly to extract " Cascading Style Server" and reuse it in upcoming request/s. Thank you for your responseNikita
You can try this regex, it is working fine for me regex101.com/r/jEsTjq/1ararar

1 Answers

1
votes

Using regular expressions for parsing XML is not the best idea, JMeter comes with XPath Extractor which allows executing arbitrary XPath queries in order to get the data from XML/XHTML/HTML responses.

So instead of trying to create an ugly fragile multiline regular expression which will break if the order of attributes change or if the response will come as a single line you could come up with a simple readable and maintainable XPath query, in your case it would be something like:

//com.mfs.model.connector.ConnectorBrowseInfo/name/text()

Demo:

enter image description here

More information: