A message analysis method, device, equipment, medium and product

By processing the hierarchical nested structure of message files and traversing recursive functions, combined with language field translation, the problem of poor readability of message parsing results was solved, achieving efficient message data analysis and improved user experience.

CN119583683BActive Publication Date: 2025-12-05CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411577016.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2025-12-05
Estimated Expiration
2044-11-06

AI Technical Summary

Technical Problem

Existing message parsing methods produce results with poor readability and fail to preserve the original hierarchical nesting structure of the message, making it difficult to effectively assist users in extracting key information.

Method used

The element tree object and element content are processed according to the hierarchical nesting structure of the message file to be processed. A recursive function is called to traverse the element tree and save the element tree object and content according to a preset format. The text content is determined by combining the preset language field correspondence and the target parsed message is obtained.

Benefits of technology

It preserves the original hierarchical nesting structure of messages, improves the readability of parsed messages and user analysis efficiency, simplifies the message data analysis process, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583683B_ABST
    Figure CN119583683B_ABST
Patent Text Reader

Abstract

The application discloses a message analysis method, device, equipment, medium and product. The application relates to the technical field of computer application. The method comprises the following steps: processing element tree objects and element contents of the element tree objects according to a hierarchical nested structure of a to-be-processed message file, obtaining element trees existing in multiple hierarchical architectures, and the multiple hierarchical architectures being consistent with the hierarchical nested structure of the to-be-processed message file; starting from a root node of the element trees, traversing the element trees in a downward direction, saving the obtained element tree objects and element contents according to a preset format, and obtaining a to-be-used analysis message; determining text content of the element tree objects in the to-be-used analysis message according to a preset language field corresponding relationship, and obtaining a target analysis message corresponding to the to-be-processed message file. The application can obtain the target analysis message corresponding to the to-be-processed message file, the original hierarchical nested structure of the to-be-processed message file is reserved, the target analysis message is better in readability, and the target analysis message is more convenient for users to analyze data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer application, and particularly relate to a message analysis method, device, equipment, medium and product. BACKGROUND

[0002] It is well known that a message string contains a large amount of useful information, and by analyzing the message, key information represented by the message required by a business personnel can be obtained, for example, in an interface test scenario, key information representing whether an interface is abnormal can be extracted from a response message.

[0003] In related technologies, a message is usually preliminarily analyzed by a parser such as a Document Object Model (DOM) or a Simple API for XML (SAX) based on stream to assist a business personnel in further message analysis and obtaining required key information. However, the message analysis result obtained based on the parser is poor in readability and difficult to retain the original hierarchical nested structure of the message, so as to be difficult to effectively assist a user in extracting key information from the message. SUMMARY

[0004] Embodiments of the present application provide a message analysis method, device, equipment, medium and product to solve the technical problem that the message analysis result obtained by a current message analysis method is poor in readability and difficult to retain the original hierarchical nested structure of the message, so as to be difficult to effectively assist a user in extracting key information from the message.

[0005] In a first aspect, embodiments of the present application provide a message analysis method, which comprises:

[0006] processing an element tree object and element content of the element tree object according to a hierarchical nested structure of a to-be-processed message file to obtain an element tree with multiple hierarchical architectures, wherein a node of the element tree is an element tree object, attribute information of the element tree object is element content, and the multiple hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file;

[0007] calling a recursive function to start downlink traversal of the element tree from a root node of the element tree, and saving the obtained element tree object and element content in a preset format to obtain a to-be-used analysis message;

[0008] determining text content of the element tree object in the to-be-used analysis message according to a preset language field corresponding relationship created in advance to obtain a target analysis message corresponding to the to-be-processed message file.

[0009] In a second aspect, embodiments of the present application further provide a message analysis device, which comprises:

[0010] The message structured analysis module is configured to process the element tree object and element content of the element tree object according to the hierarchical nested structure of the to-be-processed message file, to obtain an element tree having a plurality of hierarchical architectures, wherein a node of the element tree is an element tree object, attribute information of the element tree object is element content, and the plurality of hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file.

[0011] The effective content extraction module is configured to call a recursive function to perform downlink traversal of the element tree from a root node of the element tree, and save the obtained element tree object and element content in a preset format, to obtain a to-be-used parsed message.

[0012] The field translation module is configured to determine text content of the element tree object in the to-be-used parsed message according to a preset language field corresponding relationship that is created in advance, to obtain a target parsed message corresponding to the to-be-processed message file.

[0013] In a third aspect, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the message parsing method according to any of the embodiments of the present application when executing the program.

[0014] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, and the program is executable on a processor to implement the message parsing method according to any of the embodiments of the present application.

[0015] In a fifth aspect, a computer program product is provided, which includes a computer program, and the computer program is executable on a processor to implement the message parsing method according to any of the embodiments of the present application.

[0016] Based on the above embodiment technical solutions, by obtaining the target analysis message corresponding to the to-be-processed message file based on analysis, the user can more conveniently analyze the interface test result of the target test interface. In the embodiment of the application, the element tree object and the element content of the element tree object are processed according to the hierarchical nested structure of the to-be-processed message file, to obtain an element tree with multiple hierarchical architectures, wherein the node of the element tree is an element tree object, the attribute information of the element tree object is element content, and the multiple hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file; a recursive function is called to start downward traversal of the element tree from the root node of the element tree, and the obtained element tree object and element content are saved in a preset format, to obtain a to-be-used analysis message; the text content of the element tree object in the to-be-used analysis message is determined according to a preset language field corresponding relationship created in advance, to obtain the target analysis message corresponding to the to-be-processed message file. Based on the embodiment technical solutions of the application, the to-be-processed message file can be analyzed to obtain the target analysis message corresponding to the to-be-processed message file, which retains the original hierarchical nested structure of the to-be-processed message file, is better in readability, and is more convenient for user data analysis, can effectively assist the user in message data analysis, improve the efficiency of the user in message data analysis, and improve the user experience. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the application, and therefore should not be regarded as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0018] Figure 1 A flowchart of a message analysis method provided for the embodiment of the application;

[0019] Figure 2 A flowchart of message structured analysis provided for the embodiment of the application;

[0020] Figure 3 A flowchart of a message analysis method provided for the embodiment of the application;

[0021] Figure 4 A flowchart of creating a preset language field corresponding relationship provided for the embodiment of the application;

[0022] Figure 5 A flowchart of a message analysis method provided for the embodiment of the application;

[0023] Figure 6A flowchart of column field translation and translation content integration provided by an embodiment of the present application is provided.

[0024] Figure 7 A structural schematic diagram of a message analysis device provided by an embodiment of the present application is provided.

[0025] Figure 8 A structural schematic diagram of an electronic device provided by an embodiment of the present application is provided. DETAILED DESCRIPTION

[0026] The present application will be further described below in conjunction with the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only the parts related to the present application are shown in the drawings, but not all the structures.

[0027] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. Meanwhile, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description, but cannot be understood as indicating or implying relative importance. The acquisition, storage, use, processing, etc. of data in the technical solutions of the present application all comply with the relevant provisions of the national laws and regulations.

[0028] It should be noted that, in the embodiments of the present application, some industry existing solutions of software, components, models, etc. may be mentioned, which should be considered as exemplary, and the purpose is only to illustrate the feasibility in the implementation of the technical solutions of the present application, but does not mean that the applicant has or will necessarily use the solutions.

[0029] The acquisition, storage, use, processing, etc. of data in the technical solutions of the present application all comply with the relevant provisions of the national laws and regulations.

[0030] Before introducing the technical solutions provided by the embodiments of the present application, the background of the embodiments of the present application and the possible application scenarios are briefly introduced, for example, in the interface test scenario, with the continuous improvement of the business systems of various industries, the number of developed interfaces is also increasing. As we all know, under normal circumstances, the meanings of fields in request messages and response messages are different, and business personnel need to be very familiar with field mapping to quickly and accurately analyze messages to obtain the required key information, for example, whether the interface is abnormal.

[0031] Currently, there are various methods for message analysis, and the analysis methods used are slightly different in different development languages and environments. For example, in Java, various libraries can be used to analyze Extensible Markup Language (XML) message files. For example, the entire XML message file is loaded into memory and constructed into a tree structure through a DOM parser, and any node in the tree is accessed through programming to achieve message analysis. Or through the SAX parser, the specific analysis method based on events reads the XML message file in real time and parses it in real time, occupying less memory. In Python, the xml.etree.ElementTree module provides an Application Programming Interface (API) to parse and create XML data, and uses an element tree to represent the data in the XML message file.

[0032] However, the DOM parser needs to load the entire XML document into memory and construct a tree structure, making it very convenient to modify and randomly access the document, but if the document is large, it will occupy a large amount of memory and the parsing time is relatively long, and the efficiency is low. SAX parsing occupies less memory and has fast parsing speed, but it is not suitable for modifying XML documents, and it does not preserve the complete structure of the document, which is a one-time parsing. And the above parsing methods all need to install Java libraries additionally, making it difficult for business personnel to operate, not easy to start, and the user experience is poor, therefore, the present application provides a message analysis method based on text analysis, which can integrate the whole process of message structured analysis, message effective content extraction, message field translation and message readability output into an integrated program for the request message or response message to be parsed, realizing business one-key message analysis and translation.

[0033] Figure 1 A flowchart of a message analysis method provided by an embodiment of the present application. The present application is applicable to the case of analyzing messages by constructing a structure tree. The method can be executed by a message analysis device, which can be realized in the form of hardware and / or software. Optionally, it is realized by an electronic device, which can be a mobile terminal, a PC terminal or a server, etc. As shown in the figure, the method comprises the following steps. Figure 1

[0034] S110, according to the hierarchical nested structure of the message file to be processed, the element tree object and the element content of the element tree object are processed to obtain an element tree with multiple hierarchical architectures.

[0035] ​The node of the element tree is an element tree object, and the attribute information of the element tree object is element content.

[0036] The processing message file can be understood as a message file to be parsed. In the embodiment of the present application, the processing message file can be preset according to the scene requirement, which is not limited here. Optionally, the processing message file can be an XML message file. For example, the XML message file can be a request message or a response message in an interface test scene. In the embodiment of the present application, the processing message file (for example, the response message of the interface test) is parsed to assist the business personnel in efficiently and accurately identifying the interface test result represented by the response message. The interface test result can include interface normal and / or interface abnormal.

[0037] The hierarchical nested structure can be understood as the hierarchical nested structure between the message data included in the processing message file. The processing message file can include multiple lines of message, and there can be a nested relationship between different lines of message. The nested relationship between different lines of message can be understood as the hierarchical nested structure. Further explanation, the XML message can include two parts of message header and message body; wherein, the message header can include security header and protocol message header; the message body can include specific general domain and message entity according to different actual business scenes; the general domain can include general domain and common domain; in summary, the message data in the XML message file is multi-layer nested.

[0038] The present application discloses a specific way of constructing an element tree which reserves the element label of the processing message file, the element text content corresponding to the element label and the original hierarchical nested structure. On the basis of the above embodiment, optionally, the element tree object and the element content of the element tree object are processed according to the hierarchical nested structure of the processing message file, to obtain an element tree with multiple hierarchical architectures, including:

[0039] The processing message file is parsed based on a data parsing function to obtain the element tree object and the element content of the element tree object in the processing message file;

[0040] The hierarchical information of the element tree object is determined according to the hierarchical nested structure of the processing message file, and the tree structure of the element tree is determined according to the hierarchical information and the corresponding element tree object;

[0041] The element tree is filled according to the element content corresponding to the element tree object, to obtain an element tree with multiple hierarchical architectures and filled with data content.

[0042] Based on the above technical solution, the element tree containing all message information of the element label, element label corresponding element text content and hierarchical nested structure in the to-be-processed message file can be obtained.

[0043] The data parsing function can parse the element label and element text content in the to-be-processed message file. In the embodiment of the application, the data parsing function can include multiple functions. Optionally, the data parsing function can include ET.parse() function, tree.getroot() function and strip() function.

[0044] Optionally, based on the data parsing function to parse the to-be-processed message file, the element tree object and element content of the element tree object in the to-be-processed message file can be obtained, which can include:

[0045] Based on the data parsing function, the multiple element labels in the to-be-processed message file and the element text content corresponding to each element label are determined, and the element tree object and the element content of the element tree object are determined based on the element label and the element text content.

[0046] Specifically, the ET.parse() function can load and parse the XML message from the specified path, and further return an ElementTree object, that is, a preliminary element tree. The root element in the XML message file is obtained by tree.getroot(), the element label is extracted by.tag, and the element text content is obtained by.text.

[0047] The element tree object can correspond to the node in the element tree, and the element tree object can be determined based on the element label in the to-be-processed message file. The element content can correspond to the attribute information of the node in the element tree, and the element content can be determined based on the element text content corresponding to the element label.

[0048] The hierarchical nested structure can be the hierarchical nested structure between the element labels in the to-be-processed message file. The hierarchical information can be understood as the information of the hierarchical relationship between the element tree objects. The hierarchical nested structure corresponds to the hierarchical information.

[0049] The element tree can be a tree constructed based on the element tree object, the element content of the element tree object and the hierarchical nested structure of the to-be-processed message file. The tree structure can be understood as the preliminary architecture of the element tree. The tree structure includes nodes and the hierarchical relationship between the nodes. The hierarchical architecture can be understood as the hierarchical architecture between the nodes in the element tree. For example, the hierarchical architecture can be the architecture of the hierarchical relationship between the parent node and the child node.

[0050] S120, calling a recursive function to traverse the element tree from a root node of the element tree, and saving the obtained element tree object and element content according to a preset format, to obtain a to-be-used parsed message.

[0051] The preset format can be understood as a format for saving the element tree object and the element content. In the embodiment of the application, the preset format can be preset according to scene requirements, which is not limited here. The preset format can be a format related to the hierarchical nested structure.

[0052] The to-be-used parsed message can be a data list, which can be used to store information contained in the element tree, that is, the data list can be used to store information contained in the to-be-processed message file.

[0053] The application discloses a specific way for saving all information contained in an element tree based on a list, and on the basis of the above embodiment, a recursive function is called to traverse the element tree from a root node of the element tree, and the obtained element tree object and element content are saved according to a preset format, to obtain a to-be-used parsed message, comprising:

[0054] The recursive function is called to traverse the element tree from the root node of the element tree.

[0055] If the element content of the next element tree object in the element tree is empty, a piece of data in the to-be-used parsed message is determined according to an indent corresponding to the hierarchical information of the next element tree object in the preset format and the next element tree object.

[0056] The indent can be understood as a specific separator, which is used to represent the hierarchical relationship between the element tree objects. In the embodiment of the application, the indent can be preset according to scene requirements, which is not limited here. For example, the indent can be a space symbol.

[0057] The application discloses a specific way for saving a message original hierarchical nested structure based on a special symbol, and on the basis of the above embodiment, the message parsing method further comprises:

[0058] If the element content of the next element tree object is not empty, a recognition separator and an indent are determined according to the hierarchical information of the next element tree object in the preset format; the recognition separator is used to splice the element tree object and the element content.

[0059] The indent, the next element tree object, the recognition separator and the element content of the next element tree object are used to determine a piece of data in the to-be-used parsed message.

[0060] Based on the above technical solution, by determining whether the element content of the element tree object is empty, targeted data extraction and storage are achieved based on the determination result.

[0061] The present invention can also store only the element tree object and the element content whose element content is not empty, so as to save memory usage for message parsing.

[0062] In this embodiment of the invention, the recursive function can be preset according to the scenario requirements, and no specific limitation is made here. The identification separator shown can be used to separate the element tree object and element content in a data set.

[0063] In this embodiment of the invention, a single piece of data in the parsed message can represent a line of message in the message file to be processed.

[0064] In summary and in combination Figure 2 , Figure 2 This is a flowchart illustrating message structured parsing as provided in an embodiment of the present invention. Optionally, the specific process of determining the message to be parsed corresponding to the message file to be processed can be as follows:

[0065] Before describing the specific process, it is important to understand, in relation to the embodiments of this invention, that the xml.etree.ElementTree package in Python is a simple and efficient library for parsing and creating XML data. The embodiments of this invention do not require the installation of other packages for message parsing; the process of message reading and structured parsing can be implemented through custom functions.

[0066] Specifically, the ET.parse() function in the library can be used to specify the path to load and parse the message file to be processed (for example, an XML message file) and return an ElementTree object; the root element of the XML message is obtained through tree.getroot(). An empty list is initialized to store the text content of the parsed message; a separator that can be used to retain the original hierarchical nested structure of the message is customized, such as a space; the number of separators represents the hierarchical nested structure relationship of the message, wherein for a parent element, 0 specific separators are set before the parent element, 1 specific separator is inserted before the child element, 2 specific separators are inserted before the child element of the child element, and so on; a for loop can be introduced to traverse the child elements of the current element (child) to determine the number of child elements of each element in the message; the tag name of the element tag is extracted through.tag, and the text content of the element is obtained through.text; a new separator, for example, a colon, is added to concatenate the element tag and the element text content, and the strip() function is used to remove the white space at the beginning and end of the message element string, including space, newline, tab, etc., to delete the irrelevant characters in the message; a recursive function is defined to traverse each line of the message, and the append() function is used to add each processed line of the message to the initialized list to obtain the message to be parsed.

[0067] The example technical solution of the present application can only parse element tags and text content with non-empty text content, thereby saving memory occupied by message analysis and improving message parsing efficiency. Specifically, the difference from the above process is that whether the text content of the element is non-empty is determined, and if it is non-empty, the corresponding parsed result string is added to the result list. The present application can selectively parse the entire XML message or only the part of the message with the field value according to different business scenarios, the latter can collect the key content of the message for business personnel, simplify the main body of the message, and enable business personnel to clearly and conveniently extract the message field with the field value, extract the focus in a large amount of useless message information, and shorten the information extraction time.

[0068] S130, determining the text content of the element tree object in the message to be parsed according to the pre-created preset language field corresponding relationship, to obtain the target parsed message corresponding to the message file to be processed.

[0069] The target parsed message can be understood as a parsed message obtained by parsing the message file to be processed. That is, the purpose of the embodiment of the present application is to parse the message file to be processed to obtain the target parsed message corresponding to the message file to be processed.

[0070] Optionally, the message parsing method further comprises: outputting the target parsed message in a target format.

[0071] The target format can be a preset format with strong data feature representation capability. In the embodiment of the present application, the target format can be preset according to the scene requirement, which is not limited here. Optionally, the target format can be a txt format.

[0072] The present application discloses a specific way of applying the message parsing method to the interface test scene. On the basis of the above embodiment, the message parsing method further comprises:

[0073] Based on the target parsed message, the interface test result of the interface returning the to-be-processed message file is determined.

[0074] In the embodiment of the present application, the to-be-processed message file can be a request message or a response message returned in the interface test scene. The interface test result can be understood as the interface test result represented by the target parsed message. The interface test result can include interface normal and / or interface abnormal.

[0075] The embodiment of the technical solution integrates the whole process of message structured parsing, message effective content extraction, message field translation and message readability output into an integrated program, realizes business one-key message parsing and translation, and can effectively assist business personnel in data analysis of the message.

[0076] Based on the above embodiment technical solution, the target test interface test result can be more conveniently analyzed by the user based on the target parsed message corresponding to the to-be-processed message file obtained by parsing. In the embodiment of the present application, the element tree object and the element content of the element tree object are processed according to the hierarchical nested structure of the to-be-processed message file, and an element tree with multiple hierarchical architectures is obtained, wherein the node of the element tree is the element tree object, the attribute information of the element tree object is the element content, and the multiple hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file; a recursive function is called to start downward traversal of the element tree from the root node of the element tree, and the obtained element tree object and element content are saved according to a preset format, and a to-be-used parsed message is obtained; the text content of the element tree object in the to-be-used parsed message is determined according to the pre-created preset language field corresponding relationship, and a target parsed message corresponding to the to-be-processed message file is obtained. Based on the embodiment of the present application, the to-be-processed message file can be parsed to obtain the target parsed message corresponding to the to-be-processed message file, which retains the original hierarchical nested structure of the to-be-processed message file, is more convenient for the user to analyze data, and has better readability, can effectively assist the user in message data analysis, improve the efficiency of the user in message data analysis, and improve the user experience.

[0077] On the basis of the above-mentioned embodiments, the preset language column field correspondence relationship can be created before determining the text content of the element tree object in the to-be-used parsed message according to the pre-created preset language column field correspondence relationship, wherein the preset language column field relationship includes the text content of the element tree object in the first language and the second language, and specific implementation manners can be referred to the detailed description of the present embodiment, wherein the same or corresponding technical terms as the above-mentioned embodiments are not described herein, Figure 3 A flowchart of a message parsing method provided in an embodiment of the present application is shown in FIG. 2. Figure 3 As shown in the figure, the message parsing method comprises the following steps:

[0078] S210, creating a preset language column field correspondence relationship, wherein the preset language column field relationship includes the text content of the element tree object in the first language and the second language.

[0079] Optionally, the creation of the preset language column field correspondence relationship comprises:

[0080] determining all optional column fields in the response message;

[0081] For all optional column fields, determining the preset language column field correspondence relationship according to the first content of the optional column field in the first language, the second content of the optional column field in the second language, and the structural category to which the optional column field belongs;

[0082] wherein the structural category is the hierarchical information of the optional column field in the response message.

[0083] wherein the preset language column field correspondence relationship can be understood as the correspondence relationship between multiple languages of the column field in the to-be-used parsed message.

[0084] The first language and the second language can represent two different languages. Optionally, the first language can be English, and the second language can be Chinese. In the embodiment of the present application, the column field in the to-be-used parsed message can be recorded and stored based on the first language.

[0085] The response message can be a response message of an interface test. In the embodiment of the present application, the response message can be a plurality of historical response messages, which can contain all element tags that can appear in the to-be-processed message file.

[0086] The text content includes the first content and the second content.

[0087] Optionally, determining all optional column fields in the response message can comprise:

[0088] For the response message, determining all optional element tags, determining all optional element tree objects based on the optional element tags, and determining all optional column fields based on the optional element tree objects.

[0089] The optional column field can be understood as a column field that can be selected, and in the embodiment of the application, each optional column field corresponds to an element tree object.

[0090] The preset language column field correspondence relationship can include a plurality of language column field sub-correspondence relationships, wherein one language column field sub-correspondence relationship corresponds to one structure category. Each language column field sub-correspondence relationship includes a plurality of element tree objects under the structure category, and the first content and the second content corresponding to each element tree object.

[0091] The structure category can be understood as a category of a hierarchical structure to which the element tree object corresponding to the optional column field belongs.

[0092] It should be understood that the XML message can include a message header and a message body; the message header can include a security header and a protocol message header; the message body can include a specific general domain and a message entity according to different actual business scenarios; the general domain can include a general domain and a common domain; in summary, the message data in the XML message file is multi-layer nested.

[0093] In summary, in the embodiment of the application, the structure category can include a message header category and a message body category, or include a security header category, a protocol message header category, a general domain category, and a message entity category, etc.

[0094] The application discloses a specific manner for constructing a preset language column field correspondence relationship for column field language translation. On the basis of the above-mentioned embodiment, the preset language column field correspondence relationship is determined according to the first content of the optional column field in a first language, the second content of the optional column field in a second language, and the structure category to which the optional column field belongs, and the specific process of creating the preset language column field correspondence relationship can be:

[0095] Initialize an empty list to store the first content in the first language, the second content in the second language, and the structure category based on the empty list;

[0096] Read the row data of the updated empty list line by line, and take the structure category in the row data as a key value in the preset language column field correspondence relationship, and take the first content and the second content as data values in the preset language column field correspondence relationship.

[0097] In summary and in combination with Figure 4 , Figure 4 A flowchart for creating a preset language column field correspondence relationship is provided in the embodiment of the application. Optionally, the specific process of creating the preset language column field correspondence relationship can be:

[0098] The English and Chinese names of the field in the message are determined, and the structure category to which the field belongs is determined to facilitate subsequent English and Chinese translation of the message field; the structure name, field English name and field Chinese name corresponding to each other are stored in a txt document in the form of three columns; the txt document is read by python, first, the number of columns is determined by reading the first row of the txt file, and the corresponding number of empty lists is initialized to store the data in each column; then, the txt file is read line by line, and the corresponding relationship is stored in a two-dimensional list; finally, the two-dimensional list is converted into a dictionary, the key value in the dictionary is the structure name of the message field in the two-dimensional list, and the value value is the two-dimensional list of the English name and Chinese name of the message field corresponding to the structure type, and the above-mentioned language field corresponding relationship is obtained, which can be used for subsequent translation of the field name in the specific structure body.

[0099] S220, according to the hierarchical nested structure of the to-be-processed message file, processing the element tree object and the element content of the element tree object to obtain an element tree with multiple hierarchical architectures.

[0100] S230, calling a recursive function to start downward traversal of the element tree from the root node of the element tree, and saving the obtained element tree object and element content according to a preset format to obtain a to-be-used parsed message.

[0101] S240, determining the text content of the element tree object in the to-be-used parsed message according to the preset language field corresponding relationship created in advance to obtain a target parsed message corresponding to the to-be-processed message file.

[0102] Based on the above embodiment technical solution, all optional field fields in the response message are determined; for all optional field fields, the preset language field corresponding relationship is determined according to the first content of the optional field field in the first language, the second content of the optional field field in the second language and the structure category to which the optional field field belongs; wherein, the structure category is the hierarchical information of the optional field field in the response message. The language field corresponding relationship for language translation of the field is created.

[0103] On the basis of the above-mentioned embodiments, each piece of data in the to-be-used parsed message can be read in sequence; the hierarchical information of the data is determined according to the indentation symbol and / or the identification delimiter in the data; if the hierarchical information meets a preset condition, it is determined whether the data includes a field value; the field value is used to represent that the element tree object in the data needs to be translated; if the field value exists, the translation content of the element tree object is determined based on a preset language field corresponding relationship; and the data is updated based on the translation content to obtain the text content of the element tree object in the to-be-used parsed message. For specific implementation manners, reference can be made to the detailed description of the present embodiment, and technical terms same as or corresponding to those in the above-mentioned embodiments will not be described herein, Figure 5 A flowchart of a message parsing method provided in an embodiment of the present application is shown in FIG. 2. Figure 5 As shown in the figure, the message parsing method comprises the following steps:

[0104] S310, the element tree object and the element content of the element tree are processed according to the hierarchical nested structure of the to-be-processed message file, and an element tree with multiple hierarchical architectures is obtained.

[0105] S320, a recursive function is called to start downward traversal of the element tree from the root node of the element tree, and the obtained element tree object and element content are saved according to a preset format, and a to-be-used parsed message is obtained.

[0106] S330, each piece of data in the to-be-used parsed message is read in sequence.

[0107] S340, the hierarchical information of the data is determined according to the indentation symbol in the data.

[0108] Specifically, the outer loop reads each piece of data in the to-be-used parsed message in sequence, and the hierarchical information of the data is determined according to the indentation symbol in the data. The hierarchical information can represent the indentation level of the indentation symbol in the data, and can also represent the hierarchical structure of the element tree object in the data.

[0109] S350, if the hierarchical information meets a preset condition, it is determined whether the data includes a field value; the field value is used to represent that the element tree object in the data needs to be translated.

[0110] If the hierarchical information meets a preset condition, it can mean that the indentation level of the indentation symbol in the data is a first indentation level and the hierarchical structure of the element tree object in the data belongs to a target structure category. In the present embodiment, the indentation level of the indentation symbol can include the first indentation level and other indentation levels under the first indentation level.

[0111] S360, if the field value exists, the translation content of the element tree object is determined based on a preset language field corresponding relationship.

[0112] In the embodiment of the present application, the first content recorded based on the first language corresponding to the element tree object can be included in the to-be-used parsed message, and the present application needs to translate the first content based on the preset language field corresponding relationship to obtain the second content (that is, the translated content) recorded based on the second language corresponding to the element tree object.

[0113] Optionally, based on the preset language field corresponding relationship, the translated content of the element tree object can include:

[0114] The outer loop traverses the data with the first indentation level in the to-be-used parsed message.

[0115] For each data with the first indentation level, if the element tree object in the data belongs to the target structure category and the data contains the field value, the element tree object and the element tree object in the data with other indentation levels under the first indentation level are translated based on the preset language field corresponding relationship created in advance to obtain the translated content of the element tree object.

[0116] The present application discloses a specific method for field language translation based on a preset language field corresponding relationship, and based on the above embodiment, optionally, if there is a field value, the translated content of the element tree object is determined based on the preset language field corresponding relationship, including:

[0117] If there is a field value, the key value is determined based on the element tree object and the corresponding hierarchical information.

[0118] Based on the target function and the key value, the data value corresponding to the element tree object is retrieved from the preset language field corresponding relationship, and the data value is used as the translated content.

[0119] Based on the above technical solution, accurate and efficient field translation of the element tree object is realized.

[0120] In the embodiment of the present application, the preset language field corresponding relationship can include a plurality of key values. The preset language field corresponding relationship can include a plurality of field sub-corresponding relationships. The key value and the field sub-corresponding relationship can be one-to-one. One key value can represent one target structure category, and one field sub-corresponding relationship can store the English and Chinese field name mapping relationship of a plurality of element tree objects in one target structure category.

[0121] The target function can be used for text translation and can be preset according to the scene requirement, which is not limited here. The target function can be a custom function.

[0122] Specifically, the key value is used to determine a target field sub-correspondence relationship in a preset language field correspondence relationship, the data value corresponding to the element tree object is called in the target field sub-correspondence relationship, and the data value is used as the translation content.

[0123] The data value corresponding to the element tree object is called in the target field sub-correspondence relationship, and the data value is used as the translation content.

[0124] The text content corresponding to the element tree object recorded in the to-be-used parsed message is used as the first content.

[0125] The first content is used to determine the second content corresponding to the first content in the target field sub-correspondence relationship, wherein the sub-field correspondence relationship includes a plurality of element tree objects and text content corresponding to each element tree object, and the text content includes a mapping relationship between the first content and the second content.

[0126] The second content is used as the translation content.

[0127] Optionally, the element tree objects in the data of other indentation levels under the first indentation level are translated based on the preset language field correspondence relationship, to obtain the translation content of the element tree objects, including:

[0128] The target field sub-correspondence relationship is determined based on the target structure category corresponding to the element tree object in the data of the first indentation level, wherein the sub-field correspondence relationship includes a plurality of element tree objects and text content corresponding to each element tree object, and the text content includes a mapping relationship between the first content and the second content.

[0129] The element tree objects in the data of other indentation levels under the first indentation level are iterated in an inner loop, and for each element tree object, the second content corresponding to the first content in the target field sub-correspondence relationship is determined based on the first content of the element tree object recorded in the to-be-used parsed message.

[0130] The second content is used as the translation content.

[0131] S370, update the data based on the translation content, to obtain the text content of the element tree object in the to-be-used parsed message.

[0132] The specific way of storing the translation content corresponding to the obtained element tree object is disclosed, and based on the above embodiment, the data is updated based on the translation content, including:

[0133] The translation content is added to an adjacent field of a target field of the element tree object based on a preset field relationship, to obtain updated data.

[0134] The preset field relationship can be a field relationship when storing the element tree object and the translated content. In the embodiment of the present application, the preset field relationship can be preset according to the scene requirement, which is not limited here. Optionally, the adjacent field can be a next field adjacent to the target field.

[0135] Based on the above technical solution, the adjacent field-based manner for adding the translated content can make the readability of the update data displayed in the target parsed message better.

[0136] S380, obtaining a target parsed message corresponding to the to-be-processed message file.

[0137] In summary and in combination with Figure 6 , Figure 6 A flowchart of field translation and translated content integration is provided for the embodiment of the present application. That is, the overall flowchart of the target parsed message is determined based on the to-be-used parsed message, and the specific process can be as follows:

[0138] On the basis of obtaining the initial parsed message result list (i.e., the to-be-used parsed message), the Chinese field name dictionary corresponding to each message structure type (i.e., the preset language field corresponding relationship) is used to loop through the list elements representing the content of each line of the message in the message result list (i.e., each piece of data), and the matched Chinese field name is marked after the original English field name in the message. At the same time, the structured display after the message parsing and translation is ensured according to the indentation symbol and the identification delimiter, and the specific message field display of the target parsed message can be displayed in the order of "field English name + field Chinese name + field message value". The specific implementation method can be realized in python through a double-layer nested for loop. Further detailed description is as follows:

[0139] First, the preset storage message structure (target structure category) and the English and Chinese name dictionary of each field corresponding to each structure (i.e. field sub-corresponding relationship) are used to define the function find_value, and the target field English name (i.e. the first content of the element tree object) is input, and the corresponding field Chinese name (i.e. the second content) is returned. Then, a new null list is initialized to store the final parsed and translated content of each line of the message. The initial parsed message content list is looped (called outer loop) to determine whether the current message element is an element in the message structure category set (i.e. whether it belongs to the target structure category, such as the message header category, the message body category, and various general domain categories). If so, it is directly stored in the result list corresponding to the target parsed message. In order to identify the parent-child relationship between adjacent lines of the message, the number of leading space characters of each line of the message string can be counted, and the message string of all lines after the current line can be looped (called sub-loop) to achieve this. If the number of leading space characters (count2) of the message line in the sub-loop is exactly equal to the number of leading space characters (count1) of the message line in the outer loop plus 1, then the current message element in the sub-loop is the child element of the message element in the outer loop. Then, the current message element line is determined whether it contains a field value input according to the identification delimiter. Since the elements in the initial parsed message list each represent a line of message element content, the format is fixed, so the invention can obtain the English field name in the message element string by segmentation, and then obtain the corresponding Chinese field name by calling the previously defined find_value() function. Then, the translated message string of the current line is added to the new result list by splicing and the like. When the condition count2=count1+1 no longer holds, the message element of the current sub-loop is not a child element of the message element in the outer loop, and the sub-loop needs to be interrupted in time to enter the next outer loop corresponding to the next first indentation level.

[0140] Further, the target parsed message can be output for readability. Specifically, the result list can be written into a txt file by using the withopen() function in python. The output document retains the corresponding structure of the original XML message and retains the valid information. The message field is translated to improve the ease of understanding of the message content and enhance the readability of the message content.

[0141] Based on the technical scheme of the above embodiment, each piece of data in the to-be-used parsed message is read in sequence, the hierarchical information of the data is determined according to the indentation symbol and / or the identification delimiter in the data, whether the data includes a field value is determined if the hierarchical information meets a preset condition, wherein the field value is used to represent that an element tree object in the data needs to be translated, the translation content of the element tree object is determined based on a preset language field corresponding relationship if the field value exists, and the data is updated based on the translation content to obtain the text content of the element tree object in the to-be-used parsed message. The language translation of the element tree object in the to-be-used parsed message is realized, so that the target parsed message obtained includes the text content of the element tree object recorded in a language with better readability.

[0142] According to the technical scheme of the present application, from the perspective of facilitating test and use of the message by business personnel, the whole process of message structured parsing, message effective content extraction, message field translation and message readability output is integrated into an integrated program to realize business one-key message parsing and translation. With the help of the python tool, the field Chinese field corresponding to the field English field of the message is embedded in the message content, the parent-child structure of the message is preserved, the XML message is parsed into a txt file with very strong readability, and this is helpful for users to efficiently extract the required key information from the parsed results.

[0143] Figure 7 A structural schematic diagram of a message parsing device provided by the embodiment of the present application is shown in FIG. 4. Figure 7 As shown in the figure, the device includes a message structured parsing module 410, an effective content extraction module 420 and a field translation module 430.

[0144] The message structured parsing module 410 is configured to process the element tree object and the element content of the element tree object according to the hierarchical nested structure of the to-be-processed message file to obtain an element tree with multiple hierarchical architectures, wherein the node of the element tree is an element tree object, the attribute information of the element tree object is element content, and the multiple hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file. The effective content extraction module 420 is configured to call a recursive function to start downward traversal of the element tree from the root node of the element tree and save the obtained element tree object and element content in a preset format to obtain a to-be-used parsed message. The field translation module 430 is configured to determine the text content of the element tree object in the to-be-used parsed message according to a preset language field corresponding relationship created in advance to obtain a target parsed message corresponding to the to-be-processed message file.

[0145] Based on the technical solutions in the above embodiments, the target analysis message corresponding to the to-be-processed message file can be obtained based on analysis, so that the user can analyze the interface test result of the target test interface more conveniently. In the embodiments of the present application, the element tree object and element content of the element tree object are processed according to the hierarchical nested structure of the to-be-processed message file, to obtain an element tree with multiple hierarchical architectures, wherein the node of the element tree is an element tree object, the attribute information of the element tree object is element content, and the multiple hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file; a recursive function is called to start downward traversal of the element tree from the root node of the element tree, and the obtained element tree object and element content are saved in a preset format, to obtain a to-be-used analysis message; the text content of the element tree object in the to-be-used analysis message is determined according to a preset language field corresponding relationship, to obtain the target analysis message corresponding to the to-be-processed message file. Based on the technical solutions in the embodiments of the present application, the to-be-processed message file can be analyzed to obtain the target analysis message corresponding to the to-be-processed message file, which retains the original hierarchical nested structure of the to-be-processed message file, is more convenient for the user to analyze data, and is better in readability, can effectively assist the user in message data analysis, improve the efficiency of the user in message data analysis, and improve the user experience.

[0146] Optionally, the message analysis apparatus further includes a field relationship creation module configured to create the preset language field corresponding relationship, wherein the preset language field corresponding relationship includes text content of the element tree object in a first language and a second language.

[0147] The field relationship creation module includes an optional field determination unit and a field relationship creation unit.

[0148] The optional field determination unit is configured to determine all optional fields in the response message.

[0149] The field relationship creation unit is configured to, for all the optional fields, determine the preset language field corresponding relationship according to first content in a first language, second content in a second language, and a structure category to which the optional field belongs.

[0150] The structure category is hierarchical information of the optional field in the response message.

[0151] Optionally, the field relationship creation unit is specifically configured to:

[0152] Initialize an empty list to store the first content in the first language, the second content in the second language, and the structure category based on the empty list.

[0153] read row data of the updated empty list line by line, and take a structure category in the row data as a key value in the preset language column field corresponding relationship, and take the first content and the second content as data values in the preset language column field corresponding relationship.

[0154] Optionally, the message structure analysis module 410 is specifically configured to:

[0155] analyze the to-be-processed message file based on a data analysis function to obtain an element tree object in the to-be-processed message file and element content of the element tree object;

[0156] determine hierarchical information of the element tree object according to a hierarchical nested structure of the to-be-processed message file, and determine a tree structure of the element tree according to the hierarchical information and the corresponding element tree object;

[0157] fill the element tree according to the element content corresponding to the element tree object to obtain the element tree with multiple hierarchical architectures and filled data content.

[0158] Optionally, the effective content extraction module 420 is specifically configured to:

[0159] invoke the recursive function to start downlink traversal of the element tree from a root node of the element tree;

[0160] if element content of a next element tree object in the element tree is empty, determine a piece of data in the to-be-used parsed message according to an indent corresponding to hierarchical information of the next element tree object in the preset format and the next element tree object.

[0161] Optionally, the effective content extraction module 420 is further specifically configured to:

[0162] if the element content of the next element tree object is not empty, determine a recognition delimiter and an indent according to the hierarchical information of the next element tree object in the preset format; wherein the recognition delimiter is used to splice the element tree object and the element content;

[0163] determine the indent, the next element tree object, the recognition delimiter and the element content of the next element tree object as a piece of data in the to-be-used parsed message.

[0164] Optionally, the column field translation module 430 comprises a data reading unit, a hierarchical recognition unit, a condition judgment unit, a column field translation unit and a data updating unit.

[0165] The data reading unit is configured to read each piece of data in the to-be-used parsed message in sequence.

[0166] a level identification unit configured to determine level information of the data according to the indent in the data;

[0167] a condition determination unit configured to determine whether a field value is included in the data if the level information meets a preset condition, wherein the field value is used to represent that an element tree object in the data needs to be translated;

[0168] a field translation unit configured to determine translation content of the element tree object based on the preset language field corresponding relationship if the field value exists;

[0169] a data updating unit configured to update the data based on the translation content to obtain text content of the element tree object in the to-be-used parsed message.

[0170] Optionally, the field translation unit is specifically configured to:

[0171] if the field value exists, determine a key value based on the element tree object and corresponding level information;

[0172] based on a target function and the key value, call a data value corresponding to the element tree object from the preset language field corresponding relationship, and take the data value as the translation content.

[0173] Optionally, the data updating unit is specifically configured to:

[0174] add the translation content to an adjacent field of a target field where the element tree object is located based on a preset field relationship to obtain updated data.

[0175] Optionally, the message parsing apparatus further includes a parsed message application module configured to determine an interface test result of an interface returning the to-be-processed message file based on the target parsed message.

[0176] Figure 8 A structural schematic diagram of an electronic device provided by an embodiment of the present application. Figure 8 A block diagram of an exemplary electronic device 50 suitable for implementing embodiments of the present application is shown. Figure 8 The electronic device 50 shown is merely an example and should not impose any limitation on the function and use range of the embodiments of the present application.

[0177] As shown in Figure 8 The electronic device 50 is in the form of a general computing device. The components of the electronic device 50 can include, but are not limited to, one or more processors or processing units 501, system memory 502, and a bus 503 connecting different system components, including the system memory 502 and the processing unit 501.

[0178] Bus 503 represents one or more of several possible bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or local bus using any of a variety of bus structures. These architectures include, for example, without limitation, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0179] Electronic device 50 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 50 and includes both volatile and non-volatile media, removable and non-removable media.

[0180] System memory 502 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 504 and / or cache memory 505. Electronic device 50 can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 506 can be provided for reading from and writing to a non-removable, non-volatile magnetic media (not shown and typically called a "hard drive"). Figure 8 Although not shown, a magnetic hard drive, a magnetic disk drive (e.g., to read from or write to a removable, non-volatile magnetic disk (e.g., a "floppy drive" within the storage device 506 can be provided. A magnetic hard disk drive can also be provided, in these cases, each can be connected to the bus 503 by one or more data media interfaces. The memory 502 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the application. Figure 8 Program / utility 508, having a set (at least one) of program modules 507, can be stored in memory 502 by way of example, such as an operating system, one or more application programs, other program modules, and program data, each or some combination thereof, can include implementation of a network environment. Program modules 507 generally carry out the functions and / or methodologies of embodiments of the application as described herein.

[0181]

[0182] ​The electronic device 50 can also be in communication with one or more external devices 509, such as a keyboard, a pointing device, a display 510, etc.; one or more devices that enable a user to interact with the electronic device 50; and / or one or more devices (e.g., modems, network cards, etc.) that enable the electronic device 50 to communicate with one or more other computing devices. Such communication can occur via an input / output (I / O) interface 511. Still yet, the electronic device 50 can communicate with one or more networks, such as a local area network (LAN), a general wide area network (WAN), and / or a public network, such as the Internet, via a network adapter 512. As depicted, the network adapter 512 is in communication with the other components of the electronic device 50 through the bus 503. It should be appreciated that the network adapter 512 can be implemented as a wireless adapter, a wired adapter, or a combination of wireless and wired adapters. Figure 8 Other hardware and / or software modules that can be used in conjunction with the electronic device 50, such as microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc., are not shown in FIG. 5, but can be incorporated into the electronic device 50.

[0183] The processing unit 501 performs various function applications and message parsing by running programs stored in the system memory 502, such as the message parsing method provided by the embodiments of the present application.

[0184] The embodiments of the present application also provide a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to perform a message parsing method, the method comprising:

[0185] According to the hierarchical nested structure of the to-be-processed message file, the element tree object and element content of the element tree object are processed to obtain an element tree having a plurality of hierarchical architectures, wherein a node of the element tree is an element tree object, attribute information of the element tree object is element content, and the plurality of hierarchical architectures are consistent with the hierarchical nested structure of the to-be-processed message file;

[0186] A recursive function is called to traverse the element tree from a root node of the element tree to a leaf node of the element tree, and the obtained element tree object and element content are saved in a preset format to obtain a to-be-used parsed message;

[0187] Text content of the element tree object in the to-be-used parsed message is determined according to a preset language field corresponding relationship to obtain a target parsed message corresponding to the to-be-processed message file.

[0188] The computer storage medium of the embodiments of the present application can adopt any combination of one or more computer readable media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination thereof. More specific examples (non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device.

[0189] The computer readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer readable program code is embodied. Such propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a storage medium and that can communicate, propagate or transport program for use by or in connection with an instruction execution system, apparatus or device.

[0190] The program code embodied on the computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the above.

[0191] The computer program code for carrying out operations of the embodiments of the present application can be written in one or more programming languages or combinations of languages including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages such as "C" or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0192] The embodiment of the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the packet analysis method provided by any of the embodiments of the present application.

[0193] The computer program product can be implemented in one or more computer program languages, including object-oriented programming, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages, to execute the computer program code for performing the operations of the present application. The program code can be executed entirely on the user computer, partially on the user computer, as an independent software package, partially on the user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, through the Internet using an Internet service provider).

[0194] Note that the above is only the preferred embodiment of the present application and the technical principles applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims

1. A message parsing method, characterized in that, include: The element tree object and the element content of the element tree object are processed according to the hierarchical nesting structure of the message file to be processed to obtain an element tree with multiple hierarchical structures. The nodes of the element tree are element tree objects, and the attribute information of the element tree objects is the element content. The multiple hierarchical structures are consistent with the hierarchical nesting structure of the message file to be processed. The recursive function is called to traverse the element tree from the root node downwards, and the obtained element tree object and element content are saved according to the preset format to obtain the parsed message to be used. Based on the pre-created preset language field correspondence, the text content of the element tree object in the parsed message to be used is determined, and the target parsed message corresponding to the message file to be processed is obtained.

2. The method according to claim 1, characterized in that, Also includes: Create the preset language field mapping relationship, wherein the preset language field mapping relationship includes the text content of the element tree object in the first language and the second language; Creating the preset language field mapping relationship includes: Determine all optional fields in the response message; For all the optional field fields, the preset language field field correspondence is determined based on the first content of the optional field field in the first language, the second content in the second language, and the structural category to which the optional field field belongs; The structure category refers to the hierarchical information of the optional field in the response message.

3. The method according to claim 2, characterized in that, The step of determining the preset language field correspondence based on the first content of the optional field in the first language, the second content in the second language, and the structural category to which the optional field belongs includes: Initialize an empty list to store the first content in the first language, the second content in the second language, and the structure category based on the empty list; Read the row data of the updated empty list line by line, and use the structure category in the row data as the key value in the preset language field correspondence, and use the first content and the second content as the data value in the preset language field correspondence.

4. The method according to claim 1, characterized in that, The step of processing the element tree object and its element content based on the hierarchical nesting structure of the message file to be processed, to obtain an element tree with multiple hierarchical structures, includes: The message file to be processed is parsed based on the data parsing function to obtain the element tree object and the element content of the element tree object in the message file to be processed. The hierarchical information of the element tree object is determined based on the hierarchical nesting structure of the message file to be processed, and the tree structure of the element tree is determined based on the hierarchical information and the corresponding element tree object; The element tree is filled with the element content corresponding to the element tree object to obtain an element tree with multiple hierarchical structures and filled with data content.

5. The method according to claim 1, characterized in that, The recursive function is invoked to traverse the element tree downwards from the root node, and the obtained element tree object and element content are saved according to a preset format to obtain the parsed message to be used, including: The recursive function is called to traverse the element tree downwards from the root node; If the element content of the next element tree object in the element tree is empty, then based on the indentation character corresponding to the level information of the next element tree object in the preset format and the next element tree object, a piece of data in the parsing message to be used is determined.

6. The method according to claim 5, characterized in that, The method further includes: If the element content of the next element tree object is not empty, then the identification separator and indentation character are determined according to the hierarchical information of the next element tree object in the preset format; wherein, the identification separator is used to concatenate the element tree object and the element content; The indentation character, the next element tree object, the identification separator, and the element content of the next element tree object are used to determine a piece of data in the parsed message to be used.

7. The method according to claim 3, characterized in that, The step of determining the text content of the element tree object in the parsed message according to the pre-created preset language field correspondence includes: Read each piece of data in the parsed message in sequence; The hierarchical information of the data is determined based on the indentation characters in the data; If the hierarchical information meets the preset conditions, it is determined whether the data includes a field value; wherein the field value is used to indicate that the element tree object in the data needs to be translated. If a field value exists, the translation content of the element tree object is determined based on the preset language field correspondence. The data is updated based on the translated content to obtain the text content of the element tree object in the parsed message to be used.

8. The method according to claim 7, characterized in that, If a field value exists, the translation content of the element tree object is determined based on the preset language field correspondence, including: If the field value exists, the key value is determined based on the element tree object and the corresponding hierarchy information; Based on the objective function and the key value, retrieve the data value corresponding to the element tree object from the preset language field correspondence, and use the data value as the translation content.

9. The method according to claim 7, characterized in that, Updating the data based on the translated content includes: Based on the preset column relationships, the translated content is added to the adjacent column of the target column of the element tree object to obtain the updated data.

10. The method according to claim 1, characterized in that, The method further includes: Based on the target parsed message, determine the interface test result of the interface that returns the message file to be processed.

11. A message parsing device, characterized in that, include: The message structure parsing module is used to process the element tree object and the element content of the element tree object according to the hierarchical nesting structure of the message file to be processed, so as to obtain an element tree with multiple hierarchical structures. The nodes of the element tree are element tree objects, the attribute information of the element tree objects are element content, and the multiple hierarchical structures are consistent with the hierarchical nesting structure of the message file to be processed. The effective content extraction module is used to call a recursive function to traverse the element tree from the root node downwards, and save the obtained element tree object and element content according to a preset format to obtain the parsed message to be used. The field translation module is used to determine the text content of the element tree object in the parsed message to be used based on the pre-created preset language field correspondence, and obtain the target parsed message corresponding to the message file to be processed.

12. The apparatus according to claim 11, characterized in that, The device further includes: The column field relationship creation module is used to create the preset language column field correspondence, wherein the preset language column field correspondence includes the text content of the element tree object in the first language and the second language; The column field relationship creation module includes: The optional field determination unit is used to determine all optional fields in the response message; The field relationship creation unit is used to determine the preset language field correspondence relationship for all the optional field fields based on the first content of the optional field field in the first language, the second content of the optional field field in the second language, and the structural category to which the optional field field belongs. The structure category refers to the hierarchical information of the optional field in the response message.

13. A message parsing electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the message parsing method as described in any one of claims 1-10.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the message parsing method as described in any one of claims 1-10.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the message parsing method as described in any one of claims 1-10.

Citation Information

Patent Citations

  • Message data conversion method and device, electronic equipment and storage medium

    CN113568925A

  • Message generation method and device, electronic equipment and storage medium

    CN114499759A