An XML file comparison method and device, electronic equipment and storage medium

By setting a configuration table for XML file nodes, including anchor fields, comparison identifiers, and precision fields, the problem of inaccurate comparison of out-of-order XML files with the same structure is solved, resulting in more efficient and accurate comparison results.

CN115510843BActive Publication Date: 2026-05-05GUANGDONG SANWEIJIA INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG SANWEIJIA INFORMATION TECH CO LTD
Filing Date
2022-10-13
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively compare out-of-order XML files with the same structure, leading to inaccurate comparison results and a high false alarm rate.

Method used

By setting up a configuration table for each node, including anchoring fields, comparison identifiers, filtering fields, and precision fields, the comparison process can be flexibly controlled, node correspondence can be quickly determined, unnecessary comparisons can be filtered out, and comparisons can be performed based on precision values.

Benefits of technology

It improves the accuracy and speed of XML file comparison, reduces false alarms, adapts to the error tolerance in industrial design, and improves comparison efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115510843B_ABST
    Figure CN115510843B_ABST
Patent Text Reader

Abstract

This application provides an XML file comparison method, apparatus, electronic device, and storage medium. The method includes: acquiring a first XML file and a second XML file; converting the first XML file into a first tree-structured dictionary; converting the second XML file into a second tree-structured dictionary; the nodes in the first tree-structured dictionary include a configuration table, which describes the comparison method between a first node in the first tree-structured dictionary and a second node in the second tree-structured dictionary corresponding to the first node; traversing the first tree-structured dictionary, and comparing the currently traversed first node with its corresponding second node according to the configuration table, to obtain a comparison result. Implementing the above embodiments can improve the accuracy of the comparison, making the comparison results more precise.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data analysis technology, and more specifically, to an XML file comparison method, apparatus, electronic device, and storage medium. Background Technology

[0002] XML is a common computer format widely used in web pages, configurations, and data storage. When storing information, in-memory data often needs to be serialized and stored in a common data format. However, with program iterations, data structures, attributes, and values ​​often undergo subtle changes that are difficult for programmers or testers to perceive. Under the same input data, it's challenging to identify differences between the outputs of two different iterations, what those differences are, which are valid, and which are noise. A common method for comparing two XML data sets is to convert the XML data to a tree structure and then traverse all leaves for comparison. However, this method only compares out-of-order nodes within the same structure, leading to false positives in the output. Summary of the Invention

[0003] In view of this, the purpose of the embodiments of this application is to provide an XML file comparison method, apparatus, electronic device and storage medium that can compare XML files with disordered structure and improve the accuracy of comparison results.

[0004] In a first aspect, embodiments of this application provide an XML method, including:

[0005] Obtain the first XML file and the second XML file;

[0006] Convert the first XML file into a first tree dictionary data;

[0007] Convert the second XML file into a second tree dictionary data;

[0008] The nodes in the first tree dictionary data include a configuration table, which is used to describe the comparison method between the first node in the first tree dictionary data and the second node in the second tree dictionary data corresponding to the first node;

[0009] Traverse the first tree dictionary data, and compare the first node and the second node corresponding to the first node according to the configuration table of the first node being traversed, to obtain the comparison result.

[0010] In the above implementation process, unlike the prior art, the embodiments of this application improve the accuracy of the comparison by setting a corresponding configuration table for each node in the first tree structure, thereby making the comparison results more accurate.

[0011] Furthermore, the first node and the second node each include: fields;

[0012] The configuration table includes: the anchor field in the fields;

[0013] The step of traversing the first tree dictionary data and comparing the currently traversed first node with the corresponding second node based on the configuration table of the currently traversed first node to obtain the comparison result includes:

[0014] The second node is determined in the second tree dictionary data based on the anchor field of the first node currently being traversed;

[0015] The first node and the second node currently being traversed are compared to obtain the comparison result.

[0016] In the above implementation process, by setting an anchor field, the second node can be quickly determined in the second tree dictionary data, avoiding the problem of inaccurate comparison results caused by out-of-order comparison.

[0017] Furthermore, the configuration table includes: comparison identifiers for the first node and the second node;

[0018] The step of comparing the currently traversed first node and the second node to obtain the comparison result includes:

[0019] Based on the comparison identifier of the configuration table of the currently traversed first node, determine whether to compare the currently traversed first node and the second node, and obtain the comparison result.

[0020] In the above implementation process, by changing different values ​​of the comparison identifier, it is possible to flexibly set whether to compare the data in the first tree dictionary data, thereby making the comparison of the first XML file and the second XML file more targeted and improving the comparison speed of the first XML file and the second XML file.

[0021] Furthermore, the first node and the second node also include: the attribute value of the field, and the configuration table includes: the filter field in the field;

[0022] The step of comparing the currently traversed first node and the second node to obtain the comparison result includes:

[0023] Obtain the filter field of the first node from the configuration table;

[0024] The non-filtered fields of the first node are determined based on the filtered fields;

[0025] The attribute values ​​of the non-filtered fields in the first node and the second node of the current traversal are compared to obtain the comparison result.

[0026] In the above implementation process, by setting filter fields in the configuration table, fields that do not need to be compared can be flexibly skipped, thereby making the comparison process of the first XML file and the second XML file more targeted and improving the accuracy of the comparison.

[0027] Furthermore, the data in the configuration table includes: the precision field in the fields, and the precision of the precision field;

[0028] The step of comparing the attribute values ​​of the non-filtered fields in the currently traversed first node and the second node to obtain the comparison result includes:

[0029] If the non-filtered field is a precision field, the precision field of the first node and the precision field of the second node are compared according to the precision of the precision field to obtain the comparison result.

[0030] In the above implementation process, by setting a precision field and its precision value, and comparing based on the precision value, the first and second XML files can be made more accurate. In industrial design, some errors are acceptable. In existing technologies, differences are identified and then manually screened and confirmed later. Based on the above implementation method, the comparison efficiency can be improved.

[0031] Furthermore, the first node further includes: data of the child nodes of the first node; the second node further includes: data of the child nodes of the second node; the first node and the second node also each include: node name;

[0032] The step of comparing the currently traversed first node and the second node to obtain the comparison result includes:

[0033] Generate a first dictionary based on the names of the child nodes of the first node currently being traversed;

[0034] Generate a second dictionary based on the names of the child nodes of the second node;

[0035] The first dictionary and the second dictionary are compared to obtain the comparison result.

[0036] Further, the step of converting the first XML file into first tree dictionary data includes:

[0037] Obtain the test cases corresponding to the first XML file;

[0038] The test cases were executed twice to obtain a third XML file and a fourth XML file, respectively.

[0039] Based on the difference analysis of the third XML file and the fourth XML file, the difference data is obtained;

[0040] The difference data is added as a filter field to the configuration table in the first tree dictionary data.

[0041] In the above implementation process, by identifying the difference data and adding it as a filter field to the configuration table, the comparison speed can be improved.

[0042] Thirdly, an electronic device provided in this application includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method as described in any of the first aspects.

[0043] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in any of the first aspects.

[0044] Other features and advantages disclosed in this application will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the above-described technology disclosed in this application.

[0045] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0046] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A flowchart illustrating the XML file comparison method provided in this application embodiment;

[0048] Figure 2 A schematic diagram of the data structure of the nodes of the first tree dictionary data provided in this application embodiment;

[0049] Figure 3A schematic diagram of the comparison process between the first node and the second node provided in an embodiment of this application;

[0050] Figure 4 This is a schematic diagram of the data structure of the configuration table provided in an embodiment of this application;

[0051] Figure 5 Another comparison process diagram of the first node and the second node provided in the embodiments of this application;

[0052] Figure 6 A schematic diagram of an XML file provided in an embodiment of this application;

[0053] Figure 7 A schematic diagram illustrating the specific structure of the configuration table provided in this application embodiment;

[0054] Figure 8 Another comparison process diagram of the first node and the second node provided in the embodiments of this application;

[0055] Figure 9 This is a schematic diagram of the structure of the XML file comparison device provided in the embodiments of this application;

[0056] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0057] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0058] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0059] Example 1

[0060] See Figure 1 This application provides an XML file comparison method, including:

[0061] S1: Obtain the first XML file and the second XML file;

[0062] S2: Convert the first XML file into the first tree dictionary data;

[0063] S3: Convert the second XML file into second tree dictionary data; the nodes in the first tree dictionary data include a configuration table, which describes the comparison method between the first node in the first tree dictionary data and the second node corresponding to the first node in the second tree dictionary data;

[0064] S4: Traverse the first tree dictionary data, and compare the first node and the second node corresponding to the first node according to the configuration table of the first node being traversed, to obtain the comparison result.

[0065] For example, see Figure 2 This is a schematic diagram of the specific structure of the nodes in the first tree dictionary data. The tree structure includes: the _config attribute, which is the configuration table of the first tree dictionary data. The configuration table includes the comparison method between the first node in the first tree dictionary data and the second node corresponding to the first node in the second tree dictionary data.

[0066] In the above implementation process, unlike the prior art, the embodiments of this application improve the accuracy of the comparison by setting a corresponding configuration table for each node in the first tree structure, thereby making the comparison results more accurate.

[0067] See Figure 3 In one possible implementation, the first node and the second node each include: a field; the configuration table includes: an anchor field within the field; S5 includes:

[0068] S41: Determine the second node in the second tree dictionary data based on the anchor field of the first node being traversed;

[0069] S42: Compare the first and second nodes of the current traversal to obtain the comparison result.

[0070] For example, see Figure 4 This is a detailed diagram illustrating the configuration of the `XmlDiffIndex` table. `data` is specifically a list used to record anchor fields. If a node exists in the second tree dictionary whose anchor field value is equal to the anchor field value of the first node, then that node is identified as the second node.

[0071] Furthermore, different numbers of anchor fields correspond to different anchoring methods. If the number of anchor fields included in data is 1, then the anchoring method of the first node is unique anchoring. If the number of anchor fields included in data is greater than 1, then the anchoring method of the first node is combined anchoring.

[0072] Furthermore, the anchor field can be a field of the second node or a field of a child node of the second node.

[0073] For example, if none of its attribute values ​​can determine the uniqueness of a node, but its child nodes have anchoring properties, then anchoring can be done based on the attribute values ​​of the child nodes. That is, if there is a child node in the second tree dictionary that has the same field as the currently traversed child node, and the content of the field is the same, then the parent node of that node can be identified as the second node to be compared with the first node.

[0074] In the above implementation process, by setting an anchor field, the second node can be quickly determined in the second tree dictionary data, avoiding the problem of inaccurate comparison results caused by out-of-order comparison.

[0075] In one possible implementation, the configuration table includes: a comparison identifier between the first node and the second node;

[0076] The steps to compare the first and second nodes currently being traversed and obtain the comparison result include:

[0077] Based on the comparison flag in the configuration table of the first node being traversed, determine whether to compare the first and second nodes being traversed, and obtain the comparison result.

[0078] For example, see Figure 4 Here, enable is an indicator of whether the node is currently being traversed, that is, whether the attributes of the first node are being traversed and compared with the attributes of the second node in the second tree dictionary data.

[0079] In the above implementation process, by changing different values ​​of the comparison identifier, it is possible to flexibly set whether to compare the data in the first tree dictionary data, thereby making the comparison of the first XML file and the second XML file more targeted and improving the comparison speed of the first XML file and the second XML file.

[0080] See Figure 5 In one possible implementation, the first node and the second node further include: attribute values ​​of the fields, and the configuration table includes: filter fields in the fields; S52 includes:

[0081] S421: Retrieve the filter field of the first node from the configuration table;

[0082] S422: Determine the non-filtered fields of the first node based on the filtered fields;

[0083] S423: Compare the attribute values ​​of the non-filtered fields in the first and second nodes of the current traversal to obtain the comparison result.

[0084] It should be noted that in the above embodiment, S42 only compares the attribute values ​​of the first node and the attribute values ​​of the second node. See [link to documentation]. Figure 6The diagram below illustrates the first XML file. Root is the root node, a first-level node. Its child nodes Panels and Panel are second-level nodes. Panels' child nodes Panel and Line are third-level nodes. Panel's child nodes Edge are fourth-level nodes. In the first tree-structured dictionary data corresponding to this first XML file, the node corresponding to the root node Root includes the information Root version="0.0.0.1" (the field is Root, and its attribute value is 0.0.0.1), as well as the fields and attribute values ​​of its child nodes Panels and Panel. It can be understood that the content of the second-level node Panels in the first tree-structured dictionary data includes not only the content of the second-level node itself, but also the content of all the third-level nodes of Panels. The steps to generate the first tree dictionary data include: converting the first XML file into DOM data structure data, then calling Python's xml2dict function starting from the root node, inputting the configuration table data of the node, then traversing all child nodes of the root node, recording all original position indices of the child nodes under the root node, forming a list of the original positions of all nodes with the same name, and forming a dictionary with the node name. Repeating the above steps, the first tree dictionary data is finally formed.

[0085] The method for generating the second tree dictionary data is the same as that for generating the first tree dictionary data, but it does not include the step of configuring the configuration table.

[0086] For example, see Figure 4 The filter attribute values ​​are configured in "filter", see [link / reference]. Figure 7 The diagram below illustrates the specific characteristics of the filter. The filter under Root, the filter under Panels.Panel, and the filter under Line in the configuration table record the attribute values ​​to be filtered: version, ID, uid, and specialValue, respectively.

[0087] In the above implementation process, by setting filter fields in the configuration table, fields that do not need to be compared can be flexibly skipped, thereby making the comparison process of the first XML file and the second XML file more targeted and improving the accuracy of the comparison.

[0088] In one possible implementation, the data in the configuration table includes: a precision field, and the precision of the precision field. S523 includes:

[0089] If the non-filter field is a precision field, the precision fields of the first node and the second node are compared based on the precision of the precision field to obtain the comparison result.

[0090] For example, see Figure 4 Precision includes the precision field and its specific content; see [link to documentation]. Figure 7 The diagram below illustrates the configuration table. The `precision` attribute under `Panels.Panel` and the `precision` attribute under `Line` record the attribute values ​​to be compared for precision: `Length`, `Width`, and `EndX`. Let's explain `EndX` under `Line` in detail: If no precision comparison is performed, and the source data's `EndX` is "5.1" and the target data's `EndX` is "5.3", the comparison will fail. When performing a precision comparison, the string values ​​"5.1" and "5.3" are first converted to float values ​​5.1 and 5.3, and then compared according to the set precision. If the precision is an integer, the comparison passes, meaning the data is consistent; if the precision is one decimal place, the comparison fails, meaning the data is inconsistent.

[0091] In the above implementation process, by setting a precision field and its precision value, and comparing based on the precision value, the first and second XML files can be made more accurate. In industrial design, some errors are acceptable. In existing technologies, differences are identified and then manually screened and confirmed later. Based on the above implementation method, the comparison efficiency can be improved.

[0092] In one possible implementation, based on the precision field, the attributes of the anchor field can also be transformed based on the precision field, and the second node corresponding to the first node currently being traversed can be determined in the second tree dictionary data based on the transformed anchor field attributes.

[0093] Following S53, it also includes: traversing all fields and attributes of the second node of the second tree dictionary data, confirming that the data has been deleted, and adding the corresponding identifier.

[0094] See Figure 8 In one possible implementation, the data of the child nodes of the second node; the first node and the second node also respectively include: node name; S4 includes:

[0095] S43: Generate a first dictionary based on the names of the child nodes of the first node being traversed;

[0096] S44: Generate a second dictionary based on the names of the child nodes of the second node;

[0097] S45: Compare the first dictionary and the second dictionary to obtain the comparison result.

[0098] For example, see Figure 4The source and target data are now aggregated according to node names to obtain a dictionary. For example, the first node currently being traversed is Panels, which is a second-level node. Panels has three nodes with the same name, Panel and Line. Aggregation means combining nodes with the same name into a dictionary based on their child node names. For example, the three nodes with the same name Panel are aggregated into one dictionary, and Line is aggregated into another dictionary. It can be understood that the first and second dictionaries can each have multiple entries.

[0099] S45 includes: traversing the first dictionary corresponding to the first XML file, finding nodes that do not exist in the second XML file (these are deleted nodes), and adding corresponding markers; conversely, traversing the second dictionary corresponding to the second XML file, finding nodes that do not exist in the first dictionary corresponding to the first XML file (these are newly added nodes), and adding corresponding markers. If a node exists in both the first and second XML files, then using a conventional comparison algorithm, the same nodes in the first and second XML files are compared one-to-one by fields and attributes to obtain the comparison result.

[0100] S43 and S44 also include: obtaining the dictionary source_hash composed of the unique primary keys of the current nodes in the first tree dictionary data and the dictionary target_hash composed of the unique primary keys of the current nodes in the second tree dictionary data.

[0101] In the first and second dictionaries, different nodes with the same name in the same dictionary have different contents. Therefore, the contents corresponding to their anchor fields are different. Thus, different nodes with the same name use the hash value of the attribute value corresponding to their anchor fields as their index value. Based on this, source_hash and target_hash can be obtained.

[0102] S45 includes: taking the intersection and then the difference of source_hash and target_hash to find the sets of nodes that have been changed, added, or deleted, respectively; unite_hash, add_hash, and delete_hash; treating the nodes in the unite_hash set as a new, smaller-level XML data set; and recursively calling... Figure 1 The comparison was performed using the method described above, and finally all the comparison results were obtained.

[0103] In one possible implementation, the method for generating the filter field in the configuration table includes: obtaining the test cases corresponding to the first XML file; executing the test cases twice to obtain a third XML file and a fourth XML file respectively; performing a difference analysis based on the third XML file and the fourth XML file to obtain difference data; and adding the difference data as a filter field to the configuration table in the first tree dictionary data.

[0104] Discrepancy data, also known as noise data, generally refers to real-time changing data that does not affect actual business operations and is used to assist analysis. This type of data is difficult to compare in real-time, and its comparison value is low. Therefore, it needs to be filtered. For example, the same test case is executed twice in the same environment (referring to the program release branch version). The data from the two executions are used as source and target data respectively for comparison and analysis. The resulting discrepancy data is the noise data. This noise data is written into a filter table in dictionary form, and the updated configuration table becomes the filter table for formal testing.

[0105] In the above implementation process, by identifying the difference data and adding it as a filter field to the configuration table, the comparison speed can be improved.

[0106] Example 2

[0107] See Figure 9 This application provides an XML file comparison device, comprising:

[0108] Module 1 is used to retrieve the first XML file and the second XML file;

[0109] Transformation module 2 is used to convert the first XML file into first tree dictionary data;

[0110] Transformation module 2 is also used to convert the second XML file into second tree dictionary data;

[0111] The nodes in the first tree dictionary data include a configuration table, which describes the comparison method between the first node in the first tree dictionary data and the second node corresponding to the first node in the second tree dictionary data.

[0112] The comparison module 3 is used to traverse the first tree dictionary data, compare the first node being traversed with the second node corresponding to the first node being traversed, and obtain the comparison result based on the configuration table corresponding to the first node being traversed.

[0113] In one possible implementation, the first node and the second node each include: fields; the configuration table includes: anchor fields in the fields; the comparison module is further used to determine the second node in the second tree dictionary data based on the anchor fields of the currently traversed first node; and to compare the currently traversed first node and the second node to obtain a comparison result.

[0114] In one possible implementation, the configuration table includes: a comparison identifier for the first node and the second node; the comparison module is further configured to determine whether to compare the currently traversed first node and the second node based on the comparison identifier of the configuration table of the currently traversed first node, and obtain the comparison result.

[0115] In one possible implementation, the first node and the second node further include: attribute values ​​of fields, and the configuration table includes: filter fields in the fields; the comparison module is also used to obtain the filter fields of the first node in the configuration table; determine the non-filter fields of the first node based on the filter fields; and compare the attribute values ​​of the non-filter fields in the currently traversed first node and the second node to obtain the comparison result.

[0116] In one possible implementation, the data in the configuration table includes: a precision field in the field and the precision of the precision field; the comparison module is also used to compare the precision field of the first node and the precision field of the second node according to the precision of the precision field if the non-filtered field is a precision field, and obtain the comparison result.

[0117] In one possible implementation, the first node further includes: data of the child nodes of the first node; the second node further includes: data of the child nodes of the second node; the first node and the second node also each include: node name; the comparison module is further configured to generate a first dictionary based on the child node names of the currently traversed first node; generate a second dictionary based on the child node names of the second node; compare the first dictionary and the second dictionary to obtain a comparison result.

[0118] In one possible implementation, the conversion module is also used to obtain the test cases corresponding to the first XML file; execute the test cases twice to obtain the third XML file and the fourth XML file respectively; perform difference analysis based on the third XML file and the fourth XML file to obtain difference data; and add the difference data as a filter field to the configuration table in the first tree dictionary data.

[0119] This application also provides an electronic device, please refer to [link to application]. Figure 10 , Figure 10 This is a structural block diagram of an electronic device provided in an embodiment of this application. The electronic device may include a processor 101, a communication interface 102, a memory 103, and at least one communication bus 104. The communication bus 104 is used to enable direct communication between these components. In this embodiment, the communication interface 102 of the electronic device is used for signaling or data communication with other node devices. The processor 101 may be an integrated circuit chip with signal processing capabilities.

[0120] The processor 101 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or the processor 101 can be any conventional processor.

[0121] The memory 103 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc. The memory 103 stores computer-readable instructions. When these computer-readable instructions are executed by the processor 101, the electronic device can perform the various steps involved in the above method embodiments.

[0122] Alternatively, the electronic device may also include a storage controller and an input / output unit.

[0123] The memory 103, memory controller, processor 101, peripheral interface, and input / output unit are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 104. The processor 101 is used to execute executable modules stored in the memory 103, such as software function modules or computer programs included in electronic devices.

[0124] Input / output units are used to enable users to create tasks and set optional start periods or preset execution times for those tasks, facilitating user-server interaction. Input / output units can be, but are not limited to, a mouse and keyboard.

[0125] Understandable. Figure 10 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 10 The more or fewer components shown, or having the same Figure 3 The different configurations shown. Figure 10The components shown can be implemented using hardware, software, or a combination thereof.

[0126] This application also provides a computer-readable storage medium storing instructions. When the instructions are executed on a computer, the computer program is executed by a processor to implement the method of the method embodiment. To avoid repetition, the details will not be repeated here.

[0127] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0128] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0129] If a function is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0130] The above are merely embodiments of this application and are not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0131] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0132] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

Claims

1. A method for comparing XML files, characterized in that, include: Obtain the first XML file and the second XML file; Convert the first XML file into a first tree dictionary data; Convert the second XML file into a second tree dictionary data; In the first tree dictionary data, a corresponding configuration table is set for each node. The configuration table is used to describe the comparison method between the first node in the first tree dictionary data and the second node corresponding to the first node in the second tree dictionary data. Traverse the first tree dictionary data, and compare the first node and the second node corresponding to the first node according to the configuration table of the first node being traversed, to obtain the comparison result; The first node and the second node each include: fields; the configuration table includes: filter fields in the fields, and comparison identifiers between the first node and the second node; the method for generating the filter fields includes: Obtain the test cases corresponding to the first XML file; The test cases were executed twice in the same environment to obtain a third XML file and a fourth XML file, respectively. Based on the difference analysis of the third XML file and the fourth XML file, the difference data is obtained; Add the difference data as a filter field to the configuration table in the first tree dictionary data; The configuration table includes: a comparison identifier between the first node and the second node; The step of comparing the currently traversed first node with the corresponding second node to obtain the comparison result includes: Based on the comparison flag of the configuration table of the currently traversed first node, determine whether to compare the currently traversed first node with the corresponding second node.

2. The XML file comparison method according to claim 1, characterized in that, The configuration table includes: the anchor field in the fields; The step of traversing the first tree dictionary data and comparing the currently traversed first node with the corresponding second node based on the configuration table of the currently traversed first node to obtain the comparison result includes: Based on the anchor field of the first node currently being traversed, the second node is determined in the second tree dictionary data; The first node and the second node currently being traversed are compared to obtain the comparison result.

3. The XML file comparison method according to claim 1, characterized in that, The first node and the second node further include: the attribute value of the field; the step of comparing the currently traversed first node and the second node corresponding to the currently traversed first node to obtain the comparison result includes: Obtain the filter field of the first node from the configuration table; The non-filtered fields of the first node are determined based on the filtered fields; The attribute values ​​of the non-filtered fields in the first node and the corresponding second node of the current traversal are compared to obtain the comparison result.

4. The XML file comparison method according to claim 3, characterized in that, The data in the configuration table includes: the precision field in the fields, and the precision of the precision field; The step of comparing the attribute values ​​of the non-filtered fields in the currently traversed first node and the corresponding second node to obtain the comparison result includes: If the non-filtered field is a precision field, the precision field of the first node and the precision field of the corresponding second node are compared according to the precision of the precision field to obtain the comparison result.

5. The XML file comparison method according to claim 1, characterized in that, The first node further includes: data of the child nodes of the first node; the second node further includes: data of the child nodes of the second node; the first node and the second node also each include: node name; The step of comparing the currently traversed first node with the corresponding second node to obtain the comparison result includes: Generate a first dictionary based on the names of the child nodes of the first node currently being traversed; Generate a second dictionary based on the child node names of the corresponding second node; The first dictionary and the second dictionary are compared to obtain the comparison result.

6. An XML file comparison apparatus, used to implement the method as described in any one of claims 1-5, characterized in that, include: The acquisition module is used to acquire the first XML file and the second XML file; The conversion module is used to convert the first XML file into first tree-shaped dictionary data; The conversion module is also used to convert the second XML file into second tree dictionary data; In the first tree dictionary data, a corresponding configuration table is set for each node. The configuration table is used to describe the comparison method between the first node in the first tree dictionary data and the second node corresponding to the first node in the second tree dictionary data. The comparison module is used to traverse the first tree dictionary data, compare the first node being traversed with the second node corresponding to the first node being traversed, and obtain the comparison result.

7. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Unity-based prefabricated part editing method and device, and storage medium

    CN111552468A

  • System and method for customized file comparison

    US20110072027A1