Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to apply data assertions in XML format

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to apply data assertions in XML format". In daily operation, I believe that many people have doubts about how to apply data assertions in XML format. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about how to apply data assertions in XML format. Next, please follow the editor to study!

0x01, XML format data assertion related configuration elements

HTML assertion

XML assertion

XML Schema assertion

XPath assertion

XPath3 assertion

The role of 0x02, various XML assertions

1. HTML assertion

Check whether the format of the returned data conforms to the relevant standards of the specified format.

Location 1: name, comment

Location 2:Tidy Settings,Doctype has four options: auto, omit, strict, and loose; it specifies how to declare the DOCTYPE in the HTML generated by Tidy

Location 3: format type, that is, in which format to assert the content returned, html, xhtml, and xml?

Location 4: maximum acceptable value setting

Error threshold: maximum acceptable number of errors

Warning threshold: maximum acceptable alerts

If "Error only" is checked, Warning is ignored and only Error is statistically checked. If the check result of the returned content does not exceed the specified result, the assertion passes, otherwise it fails.

Location 5: file path where the JTidy report is saved

2. XML assertion

Determine whether the data returned by the interface requested by the sampler conforms to the XML format, that is, whether it appears in pairs.

3. XML Schema assertion

Determine whether the data returned by the interface requested by the sampler conforms to the XML Schema definition.

The role of XML Schema is to define the legality of XML documents, similar to DTD.

XML Schema definition:

Elements that can appear in a document

Attributes that can appear in the document

Which element is a child element

Order of child elements

The number of child elements

Whether the element is empty or can contain text

Data types of elements and attributes

Default values and fixed values for elements and attributes

4. XPath assertion

Determine whether the data returned by the interface requested by the sampler conforms to the XPath expression

5. XPath3 assertion

Determine whether the data returned by the interface requested by the sampler conforms to the XPath 2 expression

Note: XPath is a language for finding information in XML documents. XPath is divided into 1.0 and 2.0 versions. It uses path expressions to select nodes or node sets in an XML document. The XPath assertion is similar to the XPath extractor configuration and use, except that the XPath extractor extracts node information from the document that meets the conditions of the path expression. The XPath assertion is to determine that there are nodes in the document that meet the conditions of the path expression.

Application of 0x03, XML assertion and XPath assertion

Assertion scope:

Main sample and sub-samples: can be applied to both the main sampler and the subsampler. For example, a HTTP sampler with embedded resources

Main sample only: can only be applied to the main sampler

Sub-samples only: can only be applied to child samplers

JMeter Variable Name to use: apply to a variable with the specified name (that is, extract the value of the specified variable)

XML parsing options: setting options related to parsing XML data

① Use Tidy (tolerant parser): uses Tidy (fault-tolerant parser), which defaults to Quiet (not shown).

Quiet does not display, Report errors error report, Show warnings display warning

② Use Namespaces: using namespaces

③ Validate XML: verifying XML

④ Ignore Whitespace: ignore spaces

⑤ Fetch external DTDs: get external DTDs

XPath assertion: XPath assertion expression, you can click the "verify" button to check the correctness of the XPath expression.

At this point, the study on "how to apply data assertions in XML format" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report