XML file analysis management method and device, equipment and storage medium

The XML file is parsed and managed through the document object model (DOM), and a parsed tree structure is built, which solves the problem of low parsing efficiency of XML file in the existing technology, and realizes efficient and accurate XML file query and management.

CN119513364APending Publication Date: 2025-02-25WUHAN SHIP COMM RES INST (NO 722 RES INST OF CHINA STATE SHIPBUILDING CORP)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411535990.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, ordinary IO streams do not provide special parsing functions for XML files. For large XML files, using ordinary IO streams to read and process line by line will be very time-consuming. Manual parsing XML data usually requires more computing and memory resources, reducing the efficiency of parsing and management.

Method used

The XML file to be parsed is parsed through the Document Object Model (DOM), and a parsing tree structure containing multiple nodes is constructed, and the target node information is found and managed from the parsing tree structure according to the preset query requirements and the node name to be queried.

Benefits of technology

This method greatly improves the efficiency and accuracy of analyzing XML files, simplifies the query process, significantly improves query efficiency, and provides flexible file management capabilities to ensure the accuracy and consistency of file content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513364A_ABST
    Figure CN119513364A_ABST
Patent Text Reader

Abstract

The invention discloses an XML file analysis management method and device, equipment and a storage medium, and relates to the technical field of file management.The method comprises the steps that a to-be-analyzed XML file is analyzed through a document object model, and an analysis tree structure of the to-be-analyzed XML file with multiple nodes is obtained; searching to-be-queried node information from the analyzed tree structure according to a preset query requirement and a to-be-queried node name, and returning a leaf node structure array; and managing target node information according to a preset file management requirement and the analyzed tree structure. According to the method, the XML file is analyzed by using the document object model, and the element relationship of the XML file is clearly reflected, so that the accuracy and efficiency of file analysis are greatly improved, required information can be quickly obtained and the content of the XML file can be modified through simple query and management operations, and the working efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of file management, and more specifically, to a method, device, equipment and storage medium for parsing and managing XML files. Background Art

[0002] XML originated from Standard Generalized Markup Language (SGML), which provides a simpler, more flexible, easier to understand and process markup language, and is widely used in computer systems, such as configuration files, data exchange formats, document tags, and many other fields. It provides a standardized and normalized way to describe and process information, and promotes interoperability and data sharing between different systems.

[0003] In the prior art, the parsing management method of XML files is generally to open the XML file through a common IO stream (input / output stream), use string operations or regular expressions to preliminarily process the XML content, pass the read XML content to a dedicated XML parsing library, use the API provided by the XML parsing library, traverse or query the XML tree structure, and extract the target data.

[0004] However, in the parsing management of XML files in the prior art, ordinary IO streams are mainly used for file reading and writing operations, and do not provide special parsing functions for XML files. For large XML files, using ordinary IO streams to read and process line by line is very time-consuming. Manual parsing of XML data usually requires more computing and memory resources, which further reduces efficiency. Summary of the invention

[0005] In response to at least one defect or improvement need in the prior art, the present invention provides a parsing management method, device, equipment and storage medium for XML files, which are used to solve the problem that ordinary IO streams in the prior art do not provide special parsing functions for XML files. For large XML files, using ordinary IO streams to read and process line by line is very time-consuming. Manual parsing of XML data usually requires more computing and memory resources, reducing the efficiency of parsing and management.

[0006] To achieve the above object, according to a first aspect of the present invention, a method for parsing and managing XML files is provided, comprising:

[0007] The document object model is used to parse the XML file to be parsed, and a parsing tree structure of the XML file to be parsed having multiple nodes is obtained;

[0008] According to the preset query requirements and the name of the node to be queried, the node information to be queried is searched from the parsed tree structure, and the leaf node structure array is returned;

[0009] Manage target node information according to preset file management requirements and parse tree structure.

[0010] In a possible implementation, searching for information of the node to be queried from the parsed tree structure according to the preset query requirement and the name of the node to be queried includes searching for all identical node information, specifically including:

[0011] According to the name of the node to be queried, all nodes to be queried with the same name are searched from the parsed tree structure;

[0012] The number of nodes to be queried with the same name is recorded in the leaf node structure array;

[0013] All child node information of the node to be queried with the same name in the parsed tree structure is recorded in the leaf node structure array.

[0014] In a possible implementation, searching for the node information to be queried from the parsed tree structure according to the preset query requirement and the node name to be queried includes searching for the same node information that meets the preset query condition, specifically including:

[0015] According to the name of the node to be queried, find the parent node information of all nodes with the same name as the node to be queried from the parsed tree structure;

[0016] Searching for information of the node to be queried that meets the preset query conditions from the parent node information with the same name as the node to be queried;

[0017] The node information to be queried that meets the preset query conditions is recorded in the leaf node structure array.

[0018] In a possible implementation, managing the target node information according to the preset file management requirements and parsing the tree structure includes adding the target node information, specifically including:

[0019] Determine all target parent node information based on target node information and parsing tree structure;

[0020] Compare and analyze the tree structure to see if there is target node information based on all target parent node information;

[0021] The target node information is added to the target parent node information where the target node information does not exist.

[0022] In a possible implementation, managing the target node information according to the preset file management requirements and parsing the tree structure includes deleting the same target node information, specifically including:

[0023] Determine all target parent node information from the parsed tree structure according to the target node information;

[0024] Delete all target node information from all target parent node information.

[0025] In a possible implementation, managing the target node information according to the preset file management requirements and parsing the tree structure includes deleting the target node information that meets the preset deletion conditions, specifically including:

[0026] Determine all target parent node information from the parsed tree structure according to the target node information;

[0027] Delete the target node information that meets the preset deletion conditions in all target parent node information.

[0028] In a possible implementation, managing the target node information according to the preset file management requirements and parsing the tree structure includes modifying the target node information, specifically including:

[0029] Determine all target parent node information based on target node information and parsing tree structure;

[0030] Compare and analyze whether the child node information of all target parent node information in the tree structure is consistent with the target node information;

[0031] Modify the child node information of all inconsistent target parent node information according to the target node information.

[0032] According to a second aspect of the present invention, there is also provided an XML file parsing management device, comprising:

[0033] A document parsing module, which is configured to parse the XML file to be parsed using a document object model to obtain a parsed tree structure of the XML file to be parsed having multiple nodes;

[0034] An information search module, which is configured to search for information of the node to be queried from the parsed tree structure according to preset query requirements and the name of the node to be queried, and return an array of leaf node structures;

[0035] The information management module is configured to manage the target node information according to preset file management requirements and the parsing tree structure.

[0036] According to the third aspect of the present invention, there is also provided an XML file parsing management device, which includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit executes the steps of any of the above-mentioned XML file parsing management methods.

[0037] According to a fourth aspect of the present invention, there is also provided a storage medium storing a computer program executable by an access authentication device, wherein when the computer program runs on the access authentication device, the access authentication device executes the steps of any of the above-mentioned XML file parsing management methods.

[0038] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:

[0039] The present invention provides a parsing management method for XML files. Through the document object model (DOM), the XML files are parsed, and a complete parsing tree structure containing multiple nodes can be constructed. This structured representation method not only makes the hierarchical relationship of the XML files clear at a glance, but also greatly improves the efficiency and accuracy of the parsing. Compared with other parsing methods, DOM parsing shows stronger adaptability and accuracy when processing complex XML structures. It allows users to quickly locate and extract required node information from the parsing tree structure according to preset query requirements and the names of the nodes to be queried. This query method not only simplifies the query process, but also significantly improves the query efficiency. At the same time, the returned leaf node structure array makes the query results more intuitive and easy to process, which provides convenience for subsequent data analysis and processing. According to the preset file management requirements, the target node information is flexibly managed, including but not limited to the addition, deletion, modification and query of nodes, the modification of attributes and the adjustment of the relationship between nodes, etc., which not only improves the flexibility of file management, but also ensures the accuracy and consistency of file content. When a large number of XML files or complex XML structures need to be processed, this method provides a more intuitive, efficient and flexible operation mode. Through simple query and management operations, the required information can be quickly obtained and the file content can be modified, thereby greatly improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 A schematic diagram of a flow chart of an embodiment of the XML file parsing management method provided by the present invention;

[0042] Figure 2 A schematic diagram of the structure of an embodiment of an XML file provided by the present invention;

[0043] Figure 3 A schematic diagram of a structure of an embodiment of a parsed tree structure of an XML file provided by the present invention;

[0044] Figure 4 A schematic diagram of a flow chart of an embodiment of searching for all identical node information provided by the present invention;

[0045] Figure 5 A schematic diagram of a flow chart of an embodiment of searching for identical node information that meets preset query conditions provided by the present invention;

[0046] Figure 6 A schematic diagram of a flow chart of an embodiment of adding target node information provided by the present invention;

[0047] Figure 7 A schematic diagram of a flow chart of an embodiment of modifying target node information provided by the present invention;

[0048] Figure 8 A schematic diagram of the structure of an embodiment of the XML file parsing management device provided by the present invention;

[0049] Fig. 9 A schematic diagram of the structure of an XML file parsing management device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0051] The terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0052] The present invention provides a method, device, equipment and storage medium for parsing and managing XML files, which are described below respectively.

[0053] See also Figure 1 , Figure 1 A flowchart of an embodiment of a method for parsing and managing XML files provided by the present invention is provided. In a specific embodiment of the present invention, a method for parsing and managing XML files is disclosed, including:

[0054] S101, parsing the XML file to be parsed using a document object model to obtain a parsed tree structure of the XML file to be parsed having multiple nodes;

[0055] S102, searching for information of the node to be queried from the parsed tree structure according to the preset query requirements and the name of the node to be queried, and returning a leaf node structure array;

[0056] S103: Manage the target node information according to the preset file management requirements and the parsing tree structure.

[0057] In the above embodiment, first, the XML file to be parsed is read through the Document Object Model (DOM). The Document Object Model loads the entire XML file into the memory and builds a tree structure, in which each node corresponds to an element or attribute in the XML file. The parsing process ensures that the integrity and hierarchical structure of the XML file are preserved, providing a solid foundation for subsequent operations.

[0058] After parsing is completed, a parsing tree structure containing multiple nodes is obtained, which clearly shows the nested and hierarchical relationships between the elements in the XML file. Each node contains detailed information such as its name, attributes, and child nodes, which facilitates subsequent query and management operations.

[0059] Before querying node information, it is necessary to clarify the query requirements and the names of the nodes to be queried. These query requirements can include conditions such as the type, attributes, and location of the node. By presetting these requirements, the accuracy and efficiency of the query operation can be ensured. According to the preset query requirements and the names of the nodes to be queried, the tree structure is traversed and parsed to find the node information that meets the conditions. During the search process, various methods and attributes provided by DOM, such as getElementsByTagName, getAttribute, etc., can be used to quickly locate the target node. The found node information is returned in the form of a leaf node structure array. The leaf node structure array contains detailed information of all qualified leaf nodes, such as node names, attribute values, etc., making the query results more intuitive and easy to process, and providing convenience for subsequent data processing and analysis.

[0060] Before performing node information management, it is necessary to clarify the file management requirements, which may include node addition, deletion, modification, and query operations, node attribute modification, node position adjustment, etc. By presetting file management requirements, the standardization and consistency of node information management operations can be ensured. According to the preset file management requirements and the parsing tree structure, corresponding management operations are performed on the target node information, which may include adding new nodes, deleting unnecessary nodes, and modifying node attribute values ​​or subnodes.

[0061] During the management process, you can use the various methods and attributes provided by DOM to quickly locate and operate the target node to ensure the accuracy and efficiency of management. When performing node information management operations, you need to ensure that the integrity of the parsed tree structure is not destroyed, including maintaining the correctness of the parent-child relationship when adding or deleting nodes, and ensuring the validity and legality of attribute values ​​when modifying node attributes.

[0062] See also Figure 2 , Figure 2 A schematic diagram of the structure of an embodiment of an XML file provided by the present invention, an XML file consists of an optional declaration and a root node; a node consists of a node name, attributes, values ​​or child nodes, wherein the node name is required, and the others are not required, the node name is enclosed in "<>", it appears in pairs, but the name must be preceded by " / ", the nodes in the paired nodes are called child nodes, a node can have one or more child nodes, and the names of the child nodes can be the same. Nodes are divided into levels, the child nodes under the root node are called first-level nodes, the child nodes under the first-level nodes are second-level nodes, and so on, nodes with no child nodes and only text elements are called leaf nodes. For example Figure 2 First1 and first2 are first-level nodes, second1 and second2 are second-level nodes, and are also sibling nodes of first-level node first2. There are multiple second2 nodes with the same name. They have the same child nodes, but the values ​​of the child nodes are different. In actual use, this usage is also very common. For example, student information, each student has student number, name, height, weight, hobbies and other information, which can be designed into a same node <student>, the following child nodes are <id> 、 <name>etc.

[0063] See also Figure 3 , Figure 3 The schematic diagram of the structure of the tree structure of the XML file provided by the present invention is a schematic diagram of the structure of the tree structure of the XML file provided by the present invention. The XML file is loaded into the memory and stored in the tree structure, which is convenient for quick search. First, the corresponding parent node is searched, and then the child node or brother node under the parent node is searched. It is much faster than reading the file in the ordinary IO stream mode.

[0064] Compared with the prior art, the present embodiment provides a method for parsing and managing XML files. By parsing XML files through the document object model (DOM), a complete parsing tree structure containing multiple nodes can be constructed. This structured representation method not only makes the hierarchical relationship of the XML file clear at a glance, but also greatly improves the efficiency and accuracy of parsing. Compared with other parsing methods, DOM parsing shows stronger adaptability and accuracy when processing complex XML structures. It allows users to quickly locate and extract required node information from the parsing tree structure according to preset query requirements and the name of the node to be queried. This query method not only simplifies the query process, but also significantly improves the query efficiency. At the same time, the returned leaf node structure array makes the query results more intuitive and easy to process, which provides convenience for subsequent data analysis and processing. According to the preset file management requirements, the target node information is flexibly managed, including but not limited to the addition, deletion, modification and query of nodes, the modification of attributes and the adjustment of the relationship between nodes, which not only improves the flexibility of file management, but also ensures the accuracy and consistency of file content. When a large number of XML files or complex XML structures need to be processed, this method provides a more intuitive, efficient and flexible operation mode. Through simple query and management operations, the required information can be quickly obtained and the file content can be modified, thereby greatly improving work efficiency.

[0065] See also Figure 4 , Figure 4 A flowchart of an embodiment of searching for all identical node information provided by the present invention. In some embodiments of the present invention, searching for the node information to be queried from the parsed tree structure according to the preset query requirements and the node name to be queried includes searching for all identical node information, specifically including:

[0066] S401, searching all nodes to be queried with the same name from the parsed tree structure according to the name of the node to be queried;

[0067] S402, recording the number of nodes to be queried with the same name in the leaf node structure array;

[0068] S403: Record all child node information of the to-be-queried node with the same name in the parsed tree structure in a leaf node structure array.

[0069] In the above embodiment, starting from the root node of the parsing tree structure, a traversal algorithm such as depth first search (DFS) or breadth first search (BFS) can be used. During the traversal process, it is checked whether the name of the current node matches the name of the node to be queried. Whenever a matching node is found, its reference or path information can be stored in a temporary list for subsequent processing.

[0070] Define a data structure (such as an array or list) to store information about each node to be queried with the same name. For each unique node name, create a new element in the leaf node structure array and initialize a counter to record the number of nodes with that name. Traverse the nodes in the temporary list, and for each node, find the element with the corresponding name in the leaf node structure array and increment its count counter.

[0071] Traverse each node in the temporary list again, for each node, traverse all its child nodes, and record the information of each child node (such as name, attribute, value, etc.). Store the collected child node information in the child node information part of the element corresponding to the name in the leaf node structure array, and record it in the leaf node structure array.

[0072] See also Figure 5 , Figure 5 A flow chart of an embodiment of searching for identical node information that meets a preset query condition provided by the present invention. In some embodiments of the present invention, searching for the node information to be queried from the parsed tree structure according to the preset query requirement and the node name to be queried includes searching for identical node information that meets the preset query condition, specifically including:

[0073] S501, searching for parent node information of all nodes with the same name as the node to be queried from the parsed tree structure according to the node name to be queried;

[0074] S502, searching for information of the node to be queried that meets the preset query condition from the parent node information with the same name as the node to be queried;

[0075] S503: Record the to-be-queried node information that meets the preset query conditions in the leaf node structure array.

[0076] In the above embodiment, the traversal is started from the root node of the parsed tree structure. During the traversal process, it is checked whether the name of the current node matches the name of the node to be queried. If it matches, the node is recorded as a candidate for the parent node with the same name as the node to be queried. For each matching node, its relevant information is collected, including the information of the node itself and its position in the tree (such as level, parent node, etc.). This information will be used in subsequent steps to further screen nodes that meet the preset query conditions.

[0077] According to the preset query requirements (such as the attribute value of the node, the number or type of child nodes, etc.), the parent node information collected in step S501 is screened. During the screening process, if a parent node meets all the preset query conditions, it is regarded as a node to be queried that meets the requirements. At the same time, it can also be considered whether the child nodes of the node meet specific conditions, because sometimes the query may involve the descendants of the node rather than just the direct child nodes. For each node to be queried that meets the requirements, its relevant information is recorded, including the node name, attribute value, location, etc., which will be used for subsequent data processing or analysis.

[0078] The created leaf node structure array is used to store the information of the nodes to be queried that meet the preset query conditions. Each element of the leaf node structure array can be a record or structure containing detailed information of the node. All the information of the nodes to be queried that meet the requirements recorded in step S502 is filled into the leaf node structure array to ensure that the information of each node is accurately and completely recorded. After filling the array, necessary verification and sorting work is performed to ensure that the information in the array is accurate and easy to process later.

[0079] See also Figure 6 , Figure 6 A flowchart of an embodiment of adding target node information provided by the present invention. In some embodiments of the present invention, managing the target node information according to the preset file management requirements and parsing the tree structure includes adding the target node information, specifically including:

[0080] S601, determining all target parent node information according to the target node information and the parsed tree structure;

[0081] S602, comparing and analyzing the tree structure to see whether there is target node information based on all target parent node information;

[0082] S603: Add target node information to target parent node information where target node information does not exist.

[0083] In the above embodiment, the specific information of the target node is clarified, including the node name, attributes, possible parent node identifiers, etc., starting from the root node of the parsed tree structure, and searching for possible parent nodes by traversal. During the traversal process, which nodes are the target parent nodes are determined according to the parent node identifier (if any) provided in the target node information or according to other logics (such as node hierarchy, attribute matching, etc.), and the information of these target parent nodes is recorded, including their positions in the tree, attributes, etc.

[0084] For each target parent node, check whether there is already a node matching the target node information in its direct child nodes. The match may be based on node name, attribute or other unique identifier. For each target parent node, record the result of whether the target node information exists. If it does, it means that the target node information already exists, so no additional node needs to be added. If it does not exist, prepare to add the target node information in the subsequent steps.

[0085] According to the target node information parsed in step S601, prepare the target node data to be added to the parsing tree structure, which may include node name, attributes, possible child nodes (if any), etc. For each target parent node that does not have target node information, insert the target node data into the child node list of its parent node, ensuring that the insertion operation complies with the rules and constraints of the parsing tree structure (such as maintaining the order of nodes, avoiding duplication, etc.). After inserting the target node, update the parsing tree structure to reflect this change, including but not limited to recalculating the hierarchy of the node, updating the references of the parent node and the child node, etc., and finally, verify the integrity and consistency of the parsing tree structure to ensure that the newly added target node information is correct. Then, according to the preset file management requirements, the updated parsing tree structure is saved in an appropriate storage medium (such as a file, a database, etc.).

[0086] In some embodiments of the present invention, managing the target node information according to the preset file management requirements and parsing the tree structure includes deleting the same target node information, specifically including:

[0087] Determine all target parent node information from the parsed tree structure according to the target node information;

[0088] Delete all target node information from all target parent node information.

[0089] In the above embodiment, first, the specific information of the target node to be deleted is clarified, including the node name, attributes, possible parent node identification (such as path or ID), etc., and the target node is located in the parsed tree structure through this information. Starting from the root node of the parsed tree structure, all parent nodes that may contain the target node are searched by traversal. In the traversal process, for each node, it is checked whether it is the parent node of the target node, which can be judged by comparing the node name, attribute or path, etc. If a match is found, the information of the parent node is recorded, including its position in the tree.

[0090] For all the target parent nodes recorded in the previous step, traverse them one by one. For each target parent node, check whether there is a node matching the target node information in its direct child nodes, which can be judged according to the node name, attribute or other unique identifier. Once a matching target node is found, delete it from the child node list of the parent node. When deleting the target node, it is also necessary to consider the possible child nodes and dependencies. When deleting the parent node, its child nodes will be deleted by default. According to the preset file management requirements, it may be necessary to recursively delete all child nodes of the target node, or retain them but update their parent node references. After deleting the target node, update the parsing tree structure to reflect this change, including but not limited to recalculating the node hierarchy, updating the references of parent nodes and child nodes, adjusting the order of nodes, etc. Finally, verify the integrity and consistency of the parsing tree structure to ensure that the deletion operation does not introduce errors or omissions, and then save the updated parsing tree structure to an appropriate storage medium (such as a file, database, etc.) according to the preset file management requirements.

[0091] In some embodiments of the present invention, managing the target node information according to the preset file management requirements and parsing the tree structure includes deleting the target node information that meets the preset deletion conditions, specifically including:

[0092] Determine all target parent node information from the parsed tree structure according to the target node information;

[0093] Delete the target node information that meets the preset deletion conditions in all target parent node information.

[0094] In the above embodiment, first of all, it is necessary to clearly understand the various information of the target node, including its name, attributes, possible parent node identifiers (such as paths, IDs, etc.), and any other features that may help accurately locate the node in the tree structure. Starting from the top of the parsed tree structure - the root node, a traversal method such as depth-first search (DFS) or breadth-first search (BFS) can be selected to find all parent nodes that may contain the target node. During the traversal process, each node is checked one by one to determine whether it is the parent node of the target node, which is usually achieved by comparing the node name, attributes or other unique identifiers. Once a match is found, the relevant information of the parent node is recorded, including its exact position in the tree.

[0095] Next, all the target parent nodes recorded in the previous step are checked one by one. For each target parent node, its directly connected child nodes are checked to see if any node meets the preset deletion conditions. The preset deletion conditions may be based on the node name, attribute value, number of child nodes, whether there are specific attributes or tags, etc. Once a node that meets the deletion conditions is found, it is removed from the list of child nodes of the parent node. During the deletion process, the node dependencies and possible chain reactions need to be considered. For example, if deleting a node causes its child nodes to become isolated nodes, then according to the preset file management requirements, these child nodes may need to be deleted at the same time. After the deletion operation is completed, the parsed tree structure needs to be updated to ensure that it remains complete and consistent, including recalculating the node hierarchy, updating the reference relationship between parent nodes and child nodes, adjusting the order of nodes, etc. Finally, the integrity and consistency of the parsed tree structure need to be verified to ensure that the deletion operation does not introduce any errors or omissions. Once the verification is passed, the updated parsed tree structure can be saved to an appropriate storage medium (such as a file, database, etc.) according to the preset file management requirements.

[0096] See also Figure 7 , Figure 7 A flowchart of an embodiment of modifying target node information provided by the present invention. In some embodiments of the present invention, managing target node information according to preset file management requirements and parsing tree structures includes modifying target node information, specifically including:

[0097] S701, determining all target parent node information according to the target node information and the parsed tree structure;

[0098] S702, comparing and analyzing whether the child node information of all target parent node information in the tree structure is consistent with the target node information;

[0099] S703: Modify the child node information of all inconsistent target parent node information according to the target node information.

[0100] In the above embodiment, first, it is necessary to clarify the specific information of the target node, including the node name, attributes, possible parent node identifiers (such as path, ID, etc.), and any other information that may help locate the node in the tree structure. Starting from the root node of the parsed tree structure, use an appropriate traversal method (such as depth-first search, breadth-first search, etc.) to find all parent nodes that may contain the target node. During the traversal process, check whether each node is the parent node of the target node, which is achieved by comparing the node name, attribute or other unique identifier. Once a match is found, record the information of the parent node, including its position in the tree.

[0101] For each recorded target parent node, traverse its direct child nodes. Compare the information of each child node with the target node information. The comparison content may include but is not limited to the node name, attribute value, child node structure, etc. If any child node information is found to be inconsistent with the target node information, record the inconsistent information, which may include inconsistent attribute values, missing or redundant child nodes, etc.

[0102] According to the inconsistent information recorded in step S702, prepare the data to be modified, which may include but is not limited to new attribute values, child nodes to be added or deleted, etc. For each inconsistent child node, perform the corresponding modification operation, which may include updating the attribute value, adding or deleting child nodes, adjusting the node structure, etc. After the modification operation is completed, update the parsing tree structure to reflect these changes, including recalculating the node hierarchy, updating the reference relationship between parent nodes and child nodes, etc. Finally, verify the integrity and consistency of the parsing tree structure to ensure that the modification operation does not introduce any errors or omissions. Once the verification is passed, save the updated parsing tree structure to an appropriate storage medium (such as a file, database, etc.) according to the preset file management requirements.

[0103] In order to better implement the XML file parsing management method in the embodiment of the present invention, based on the XML file parsing management method, correspondingly, please refer to Figure 8 , Figure 8 This is a schematic diagram of the structure of an embodiment of an XML file parsing management device provided by the present invention. The embodiment of the present invention provides an XML file parsing management device 800, including:

[0104] A document parsing module 810, which is configured to parse the XML file to be parsed using a document object model to obtain a parsed tree structure of the XML file to be parsed having multiple nodes;

[0105] An information search module 820, which is configured to search for information of a node to be queried from a parsed tree structure according to a preset query requirement and a name of a node to be queried, and return an array of leaf node structures;

[0106] The information management module 830 is configured to manage the target node information according to the preset file management requirements and the parsed tree structure.

[0107] It should be noted here that: the device 800 provided in the above embodiment can implement the technical solutions described in the above method embodiments. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above method embodiments, which will not be repeated here.

[0108] See also Fig. 9 , Fig. 9 A schematic diagram of the structure of an XML file parsing management device provided by an embodiment of the present invention. Based on the above XML file parsing management method, the present invention also provides an XML file parsing management device, which can be a computing device such as a mobile terminal, a desktop computer, a notebook, a palm computer, and a server. The XML file parsing management device 900 includes a processor 910, a memory 920, and a display 930. Fig. 9 Only some components of the synchronous tracking flying welding equipment for real-time measurement of battery height are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.

[0109] In some embodiments, the memory 920 may be an internal storage unit of the XML file parsing management device 900, such as a hard disk or memory of the XML file parsing management device 900. In other embodiments, the memory 920 may also be an external storage device of the XML file parsing management device 900, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the XML file parsing management device 900. Further, the memory 920 may also include both the internal storage unit and the external storage device of the XML file parsing management device 900. The memory 920 is used to store application software and various types of data installed in the XML file parsing management device 900, such as the program code of the XML file parsing management device 900. The memory 920 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the memory 920 stores a parsing management program 940 for XML files, and the parsing management program 940 for XML files can be executed by the processor 910, thereby realizing the parsing management method of XML files in each embodiment of the present application.

[0110] In some embodiments, the processor 910 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes stored in the memory 920 or process data, such as executing a parsing management method for XML files.

[0111] In some embodiments, the display 930 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 930 is used to display information of the XML file parsing management device 900 and to display a visual user interface. The components 910-930 of the XML file parsing management device 900 communicate with each other through a system bus.

[0112] In one embodiment, when the processor 910 executes the XML file parsing management program 940 in the memory 920, the steps in the above XML file parsing management method are implemented.

[0113] This embodiment further provides a computer-readable storage medium on which a parsing management program for XML files is stored. When the parsing management program for XML files is executed by a processor, the following steps are implemented:

[0114] The document object model is used to parse the XML file to be parsed, and a parsing tree structure of the XML file to be parsed having multiple nodes is obtained;

[0115] According to the preset query requirements and the name of the node to be queried, the node information to be queried is searched from the parsed tree structure, and the leaf node structure array is returned;

[0116] Manage target node information according to preset file management requirements and parse tree structure.

[0117] In summary, the present invention provides a method for parsing and managing XML files. Through the document object model (DOM), the XML files are parsed, and a complete parsing tree structure containing multiple nodes can be constructed. This structured representation method not only makes the hierarchical relationship of the XML file clear at a glance, but also greatly improves the efficiency and accuracy of the parsing. Compared with other parsing methods, DOM parsing shows stronger adaptability and accuracy when processing complex XML structures. It allows users to quickly locate and extract required node information from the parsing tree structure according to preset query requirements and the names of the nodes to be queried. This query method not only simplifies the query process, but also significantly improves the query efficiency. At the same time, the returned leaf node structure array makes the query results more intuitive and easy to process, which provides convenience for subsequent data analysis and processing. According to the preset file management requirements, the target node information is flexibly managed, including but not limited to the addition, deletion, modification and query of nodes, the modification of attributes and the adjustment of the relationship between nodes, which not only improves the flexibility of file management, but also ensures the accuracy and consistency of file content. When a large number of XML files or complex XML structures need to be processed, this method provides a more intuitive, efficient and flexible operation mode. Through simple query and management operations, the required information can be quickly obtained and the file content can be modified, thereby greatly improving work efficiency.

[0118] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.

[0119] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0120] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0121] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0122] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0123] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0124] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program code.

[0125] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, which can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0126] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

[0127] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0128] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.< / name> < / id> < / student>

Claims

1. A method for parsing and managing XML files, characterized in that: include: The document object model is used to parse the XML file to be parsed, and a parsing tree structure of the XML file to be parsed having multiple nodes is obtained; According to the preset query requirements and the name of the node to be queried, the information of the node to be queried is searched from the parsed tree structure, and an array of leaf node structures is returned; The target node information is managed according to the preset file management requirements and the parsed tree structure.

2. The XML file parsing management method according to claim 1, characterized in that: The searching for the node information to be queried from the parsed tree structure according to the preset query requirement and the node name to be queried includes searching for all identical node information, specifically including: According to the name of the node to be queried, searching from the parsed tree structure for all nodes to be queried with the same name; Recording the number of nodes to be queried with the same name in the leaf node structure array; All child node information of the node to be queried with the same name in the parsed tree structure is recorded in the leaf node structure array.

3. The XML file parsing management method according to claim 1, characterized in that: The searching for the node information to be queried from the parsed tree structure according to the preset query requirement and the node name to be queried includes searching for the same node information that meets the preset query condition, specifically including: According to the name of the node to be queried, searching the parsed tree structure for parent node information having the same name as all the nodes to be queried; Searching for information of the node to be queried that meets the preset query condition from the parent node information with the same name as the node to be queried; The node information to be queried that meets the preset query condition is recorded in the leaf node structure array.

4. The XML file parsing management method according to claim 1, characterized in that: The managing the target node information according to the preset file management requirements and the parsing tree structure includes adding the target node information, specifically including: Determine all target parent node information according to the target node information and the parsed tree structure; Compare the target node information in the parsed tree structure with all the target parent node information; The target node information is added to the target parent node information where the target node information does not exist.

5. The XML file parsing management method according to claim 1, characterized in that: The managing the target node information according to the preset file management requirement and the parsing tree structure includes deleting the same target node information, specifically including: Determining all target parent node information from the parsed tree structure according to the target node information; Delete all target node information in all target parent node information.

6. The XML file parsing management method according to claim 1, characterized in that: The managing the target node information according to the preset file management requirements and the parsing tree structure includes deleting the target node information that meets the preset deletion conditions, specifically including: Determining all target parent node information from the parsed tree structure according to the target node information; Delete the target node information that meets the preset deletion condition in all the target parent node information.

7. The XML file parsing management method according to claim 1, characterized in that: The managing the target node information according to the preset file management requirements and the parsing tree structure includes modifying the target node information, specifically including: Determine all target parent node information according to the target node information and the parsed tree structure; Comparing whether the child node information of all target parent node information in the parsed tree structure is consistent with the target node information; Modify the child node information of all inconsistent target parent node information according to the target node information.

8. A parsing management device for XML files, characterized in that: include: A document parsing module, which is configured to parse the XML file to be parsed using a document object model to obtain a parsed tree structure of the XML file to be parsed having multiple nodes; An information search module, which is configured to search for information of the node to be queried from the parsed tree structure according to preset query requirements and the name of the node to be queried, and return a leaf node structure array; The information management module is configured to manage the target node information according to preset file management requirements and the parsing tree structure.

9. A parsing and management device for XML files, characterized in that: It includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit executes the steps of the XML file parsing management method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: It stores a computer program executable by an access authentication device. When the computer program runs on the access authentication device, the access authentication device executes the steps of the XML file parsing management method according to any one of claims 1 to 7.