Search

CN-116582600-B - Method, system, storage medium and equipment for analyzing and constructing xml message

CN116582600BCN 116582600 BCN116582600 BCN 116582600BCN-116582600-B

Abstract

The invention discloses a method, a system, a storage medium and equipment for analyzing and constructing an xml message, wherein the method comprises the steps of determining a target variable and a node configuration rule required by constructing the target xml message according to service requirements, obtaining an original xml message, converting message content corresponding to the target variable in the original xml message into a json variable file, analyzing the json variable file to obtain variable information of the target variable, configuring the target variable into a variable node of the target xml message according to the node configuration rule, and assembling the variable information of the target variable to construct the target xml message. According to the invention, the form of xml-json-xml is adopted, so that batch message analysis and variable combination processing are automatically realized, the tedious work of repeatedly modifying and storing messages in a large amount is effectively avoided, the manpower resource waste is reduced, and the working efficiency and the accuracy are improved.

Inventors

  • LI CHUNJUAN

Assignees

  • 融慧金科金融服务外包(北京)有限公司

Dates

Publication Date
20260508
Application Date
20230403

Claims (6)

  1. 1.A method of parsing and constructing xml messages, the method comprising: determining target variables and node configuration rules required by constructing a target xml message according to service requirements; The method comprises the steps of obtaining an original xml message, converting the message content corresponding to a target variable in the original xml message into a json variable file, wherein the step of converting the message content corresponding to the target variable in the original xml message into the json variable file comprises the steps of converting the original xml message into a json format message, intercepting the message content corresponding to the target variable from the json format message according to a preset variable specification, and storing and generating the json variable file of the target variable; Analyzing the json variable file to obtain variable information of the target variable, wherein the method specifically comprises the steps of obtaining a json variable file path, and obtaining the json variable file according to the json variable file path; analyzing the json variable file to obtain the variable name and the variable value of the target variable, wherein the variable information comprises the variable name, the variable value and the attribute value; Configuring the target variable as a variable node of a target xml message according to the node configuration rule, and assembling variable information of the target variable to construct the target xml message, wherein the method specifically comprises the steps of configuring the target variable as the variable node of the target xml message according to the node configuration rule; the method comprises the steps of selecting a variable node as a current variable node, judging whether the current variable node has an attribute according to a json variable file of the current variable node, obtaining an attribute value and a variable value of the current variable node as a node value of the current variable node if the attribute exists, continuously judging whether the current variable node has a child node if the attribute exists, taking the child node as the current variable node, returning to judge whether the current variable node has an attribute step or not if the child node exists, obtaining the variable value of the current variable node as the node value of the current variable node if the child node does not exist, judging whether the current variable node is the last variable node of a target xml message, assembling all the variable nodes and the corresponding node values thereof to construct the target xml message if the attribute exists, reselecting an unprocessed variable node as the current variable node if the attribute exists, and returning to judge whether the current variable node has an attribute step or not until the last variable node is processed.
  2. 2. The method for parsing and constructing an xml message according to claim 1, wherein obtaining an original xml message includes: and acquiring an original xml message path, and acquiring the original xml message according to the original xml message path.
  3. 3. A system for parsing and constructing xml messages, the system comprising: the variable and rule determining module is used for determining target variables and node configuration rules required by constructing the target xml message according to the service requirements; the original message acquisition and conversion module is used for acquiring an original xml message and converting the message content corresponding to the target variable in the original xml message into a json variable file; the variable information analysis module is used for analyzing the json variable file to obtain variable information of the target variable; the target message construction module is used for configuring the target variable as a variable node of the target xml message according to the node configuration rule, and assembling variable information of the target variable to construct the target xml message; the original message obtaining and converting module comprises: the format conversion module is used for converting the original xml message into a json format message; The variable content intercepting module is used for intercepting the message content corresponding to the target variable from the json format message according to a preset variable specification, and storing and generating a json variable file of the target variable; the variable information comprises a variable name, a variable value and an attribute value; The variable information analysis module specifically comprises: the variable file acquisition module is used for acquiring a json variable file path and acquiring the json variable file according to the json variable file path; The variable information acquisition module is used for analyzing the json variable file to acquire the variable name and the variable value of the target variable; The target message construction module specifically comprises: the node configuration module is used for configuring the target variable as a variable node of the target xml message according to the node configuration rule; the current node selection module is used for selecting a variable node as a current variable node; the node attribute judging module is used for judging whether the current variable node has an attribute according to the json variable file of the current variable node; The attribute-containing node value acquisition module is used for acquiring the attribute value and the variable value of the current variable node as the node value of the current variable node when the node attribute judgment module judges that the current variable node has the attribute; The node attribute judging module is used for judging whether the current variable node has a child node or not when the node attribute judging module judges that the current variable node has no attribute, if so, taking the child node as the current variable node, continuously judging whether the current variable node has an attribute through the node attribute judging module, and if not, acquiring the variable value of the current variable node as the node value of the current variable node; The construction module is used for judging whether the current variable node is the last variable node of the target xml message, if so, assembling all the variable nodes and the corresponding node values thereof to construct the target xml message, if not, reselecting an unprocessed variable node as the current variable node through the current node selection module, and continuously judging whether the current variable node has the attribute through the node attribute judging module until the last variable node is processed.
  4. 4. The system for parsing and constructing xml messages according to claim 3, wherein said original message acquisition and conversion module further comprises: The original message acquisition module is used for acquiring an original xml message path and acquiring the original xml message according to the original xml message path.
  5. 5. A computer readable storage medium storing a computer program, which when executed by a processor causes the processor to perform the steps of the method according to any one of claims 1 to 2.
  6. 6. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the computer program, when executed by the processor, causes the processor to perform the steps of the method according to any of claims 1 to 2.

Description

Method, system, storage medium and equipment for analyzing and constructing xml message Technical Field The present invention relates to the field of information technologies, and in particular, to a method, a system, a storage medium, and an apparatus for parsing and constructing an xml packet. Background Xml (Extensible Markup Language ) is a general markup language, can use a series of markup description data, and is a powerful tool for processing structured document information in the current financial and technological industry. In actual work, the business requirements of analyzing the original xml message and correspondingly generating the xml format pedestrian sign message for verifying the accuracy of the test variable exist, but the existing processing mode is mainly to manually identify and analyze the original message by a test developer, then manually process the combination of the messages according to the requirements to output the finally required test message, and the working process and the result are greatly influenced by human subjective factors, so that the test accuracy is not high, and meanwhile, the human resource cost is seriously wasted, so that the test efficiency is low. Disclosure of Invention In view of the foregoing, it is desirable to provide a method, system, storage medium and apparatus for parsing and constructing xml messages. The invention discloses a method for analyzing and constructing an xml message, which comprises the following steps: determining target variables and node configuration rules required by constructing a target xml message according to service requirements; acquiring an original xml message, and converting the message content corresponding to the target variable in the original xml message into a json variable file; Analyzing the json variable file to obtain variable information of the target variable; According to the node configuration rule, configuring the target variable as a variable node of the target xml message, and assembling variable information of the target variable to construct the target xml message. Further, an original xml message is obtained, and message content corresponding to the target variable in the original xml message is converted into a json variable file, which specifically comprises: Acquiring an original xml message path, and acquiring an original xml message according to the original xml message path; converting the original xml message into a json format message; according to a preset variable specification, intercepting the message content corresponding to the target variable from the json format message, and storing and generating a json variable file of the target variable. Further, the variable information comprises a variable name and a variable value; Analyzing the json variable file to obtain variable information of the target variable, wherein the method specifically comprises the following steps: Acquiring a json variable file path, and acquiring the json variable file according to the json variable file path; and analyzing the json variable file to obtain the variable name and the variable value of the target variable. Further, the variable information also comprises attribute values; According to the node configuration rule, configuring the target variable as a variable node of a target xml message, and assembling variable information of the target variable to construct the target xml message, wherein the method specifically comprises the following steps of: according to the node configuration rule, configuring the target variable as a variable node of a target xml message; selecting a variable node as a current variable node; Judging whether the current variable node has attributes according to the json variable file of the current variable node, If the attribute exists, acquiring an attribute value and a variable value of the current variable node, and taking the attribute value and the variable value as the node value of the current variable node; If no attribute exists, continuing to judge whether the current variable node has a child node, if so, taking the child node as the current variable node, returning to a step of judging whether the current variable node has an attribute, and if not, acquiring a variable value of the current variable node as a node value of the current variable node; Judging whether the current variable node is the last variable node of the target xml message, if so, assembling all the variable nodes and the corresponding node values thereof to construct the target xml message, if not, reselecting an unprocessed variable node as the current variable node, and returning to the step of judging whether the current variable node has the attribute or not until the last variable node is processed. On the other hand, the invention also discloses a system for analyzing and constructing the xml message, which comprises: the variable and rule determining module is used for determining target