Customized multi-thread analysis method for equipment model based on XML (Extensible Markup Language) file

By configuring equipment XML files and XML parsing configuration files, constructing index tables and mapping tables, and using thread pools to parse the target equipment model and its components in parallel, the problem of excessively long XML parsing time in existing technologies is solved, achieving fast and resource-efficient multi-threaded parsing.

CN121918894APending Publication Date: 2026-04-24ZHONGKE INSIGHT TECHNOLOGY (XIAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHONGKE INSIGHT TECHNOLOGY (XIAN) CO LTD
Filing Date
2025-12-10
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing XML parsing solutions require loading and parsing all equipment and component data in the entire XML file, resulting in long parsing times and failing to meet the fast parsing requirements of actual business needs.

Method used

By configuring the equipment XML file and XML parsing configuration file, an index table and mapping table are built. A thread pool is used to allocate tasks for parallel parsing. Combined with a recursive traversal mechanism, only the necessary data of the target equipment model and its components are parsed, avoiding full parsing.

Benefits of technology

It enables rapid, customized multi-threaded parsing, optimizes resource utilization, improves parsing speed, and allows for code refactoring when adding new equipment or component types. It also automatically handles multi-level nesting of component types and attribute tags.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121918894A_ABST
    Figure CN121918894A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data analysis, in particular to a customized multi-thread analysis method for an equipment model based on an XML (Extensible Markup Language) file. Comprising the following steps: S1, configuring an equipment XML file and an XML analysis configuration file; s2, constructing an index table and a mapping table; s3, determining a target equipment model needing to be analyzed; s4, performing task allocation and recursive analysis; s5, combining and outputting analysis results; according to the equipment model customization analysis method based on the XML file, when the equipment type or the component type needing to be analyzed is newly added, only the newly added equipment type in the XML analysis configuration file and the component type and the attribute tag corresponding to the newly added equipment type need to be modified, and codes do not need to be reconstructed; and the equipment XML file can be specifically analyzed according to the equipment type, the component type list and the attribute tag list in the file through the XML analysis configuration file, so that the problems of resource waste and overlong time consumption caused by full analysis can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data parsing technology, specifically to a customized multi-threaded parsing method for equipment models based on XML files. Background Technology

[0002] In equipment model-driven applications (such as massively multiplayer online games, military simulation systems, and digital twin platforms for industrial equipment), equipment data is typically stored in XML format. A typical equipment XML file may contain hundreds or even thousands of equipment models, covering types such as weapons, armor, and items. Each equipment model is defined by tags and has fixed type (equipment type) and id (unique identifier) ​​attributes, while also containing numerous custom attribute tags (such as attack power, defense value, material parameters, etc.), and these attributes support multi-level nested structures. In addition, each piece of equipment contains multiple functional components, which are identified by tags. Each component has an independent id and type (component type) to describe the specific functional module of the equipment (e.g., the scope component of a weapon, the armor module of armor, etc.).

[0003] However, traditional XML parsing schemes (such as DOM, SAX, or XPath-based parsing) have obvious limitations: regardless of the actual business requirements, these schemes need to load and parse all the equipment and component data in the entire XML file, which leads to long parsing time. Summary of the Invention

[0004] The purpose of this invention is to provide a customized multi-threaded parsing method for equipment models based on XML files, which addresses the technical problem that existing XML parsing solutions require loading and parsing all equipment and component data in the entire XML file, regardless of actual business needs, resulting in long parsing times.

[0005] To solve the above-mentioned technical problems, the technical solution provided by the present invention is as follows: A customized multi-threaded parsing method for equipment models based on XML files includes the following steps: S1. Configure equipment XML files and XML parsing configuration files Place each equipment model within an equipment XML file, and define the starting tag for each equipment model as follows: <equip type="装备类型" id="装备唯一ID">The rest are several <comp type="组件类型" id="组件唯一ID">Tags, and custom attribute tags; Write the equipment type of each equipment model, as well as the component type list and attribute tag list corresponding to the equipment type, into the XML parsing configuration file; S2. Construct the index table and mapping table. The XML parser parses the configuration file, constructs the mapping relationship between the equipment type of each equipment model and the corresponding component type list and attribute tag list, and generates an index table. A lightweight pre-scan of the equipment XML file is performed by a parser to establish a mapping table between the unique equipment ID of each equipment model and the node position of that equipment model in the equipment XML file. S3. Determine the target equipment model that needs to be analyzed; S4. Task Allocation and Recursive Analysis The parser performs a lightweight pre-scan of the equipment XML file, filters all node positions corresponding to the target equipment model, and encapsulates the equipment model corresponding to each node position into a parsing task. Each parsing task is submitted to a thread pool, which then assigns each parsing task to an independent thread within the pool. An independent thread extracts the equipment type and unique equipment ID from the equipment model in the parsing task using a parser. Traverse all component types under the equipment model, filter out the components that match the component type list, extract the component type and unique ID of the component by a separate thread, and use the component type corresponding to the component as the target component type; Recursively traverse all attribute tags under each target component type, filter out the attribute tags that match the attribute tag list, use them as target attribute tags, and extract the values ​​of the target attribute tags; The extracted equipment unique ID, component type, component unique ID, and target attribute tag values ​​are encapsulated into structured data and stored in a shared result set; S5. After all independent threads have completed their tasks, the main thread merges the structured data from each independent thread into a shared result set, and outputs it according to the equipment's unique ID or component type, thus completing the customized multi-threaded parsing of the target equipment model.

[0006] Furthermore, in steps S2 and S4, the parser is any one of a DOM parser, a SAX parser, or an XPath parser.

[0007] Furthermore, in step S4, the independent thread extracts the equipment type and unique equipment ID of the equipment model in the parsing task through the parser, and also needs to verify whether it is the target equipment model it is responsible for. If not, the corresponding parsing task will be reallocated by the thread pool.

[0008] Furthermore, in step S4, the number of independent threads in the thread pool can be configured as needed, with a default value of twice the number of CPU cores.

[0009] Furthermore, step S5 can also be: after all independent threads have completed their tasks, the main thread merges the structured data stored in the shared result set from each independent thread and directly transmits it to the downstream business module to complete the customized multi-threaded parsing of the target equipment model.

[0010] Compared with the prior art, the beneficial effects of the present invention are as follows: The customized equipment model parsing method based on XML files provided by this invention only requires modifying the newly added equipment type and its corresponding component type and attribute tags in the XML parsing configuration file when adding new equipment types or component types that need to be parsed, without refactoring the code. Moreover, the XML parsing configuration file allows for targeted parsing of the equipment XML file based on the equipment type, component type list, and attribute tag list within the file, avoiding the resource waste and excessive time consumption caused by full parsing. Simultaneously, multiple independent threads in a thread pool parse the equipment model at different node positions in parallel, eliminating the need to load and parse all data in the entire equipment XML file, thus maximizing resource utilization and significantly improving the parsing speed of large-scale XML files. Furthermore, the recursive traversal mechanism used in the parsing process can automatically handle multi-level nesting of component types and attribute tags, eliminating the need to hard-code parsing logic for specific nesting depths. Attached Figure Description

[0011] Figure 1 This is a flowchart illustrating an embodiment of the present invention. Detailed Implementation

[0012] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0013] A customized multi-threaded parsing method for equipment models based on XML files, the specific steps of which are as follows: 1) Configure equipment XML files and XML parsing configuration files Place each equipment model within an equipment XML file, and define the starting tag for each equipment model as follows: <equip type="装备类型" id="装备唯一ID">(like" <equip type=""武器”id="weapon_001”">), the rest are several <comp type="组件类型" id="组件唯一ID">Tags (such as "blade" and "armor module"), and custom attribute tags (such as... <attack value="100" / > , <material> <density> 5.0< / density> < / material> Both component types and attribute tags support multi-level nesting. Write the equipment type (e.g., "melee weapon") of each equipment model, as well as the component type list (e.g., "blade component" "grip component") and attribute tag list (e.g., "sharpness", "material", "comfort") corresponding to the equipment type into the XML parsing configuration file; Optional global parameters (such as whether to parse nested properties, thread pool size, etc.) can also be written to the XML parsing configuration file; 2) Construct the index table and mapping table The XML parser parses the configuration file, constructs the mapping relationship between the equipment type of each equipment model and the corresponding component type list and attribute tag list, and generates an index table. That is, using equipment type as the key, it maps to the corresponding component type list and attribute tag list; for example, the index table records "melee weapon" → [blade component (type=101), grip component (type=102)], where the blade component needs to extract the attributes [sharpness, material], and the grip component needs to extract the attribute [comfort]. A lightweight pre-scan (not full parsing) of the equipment XML file is performed by a parser to establish a mapping table between the unique equipment ID of each equipment model and the node position of that equipment model within the equipment XML file; for example, the SAX parser records each <equip>The initial offset of the label facilitates subsequent orientation and positioning; 3) Determine the target equipment model that needs to be analyzed; 4) Task allocation and recursive parsing The parser performs a lightweight pre-scan of the equipment XML file, filters all node positions corresponding to the target equipment model, and encapsulates the equipment model corresponding to each node position into a parsing task. Each parsing task is submitted to a thread pool, which then assigns each parsing task to an independent thread within the pool. The number of independent threads in the thread pool can be configured as needed, with a default value of twice the number of CPU cores. An independent thread extracts the equipment type and unique equipment ID of the equipment model in the parsing task through the parser, and verifies whether it is the target equipment model it is responsible for. If not, the corresponding parsing task will be reassigned by the thread pool; Iterate through all component types under the equipment model (including component types under multiple nesting), filter out the components that match the component type list, extract the component type and unique ID of the component by a separate thread, and use the component type corresponding to the component as the target component type; Recursively traverse all attribute tags (including attribute tags under multiple levels of nesting) under each target component type, filter out the attribute tags that match the attribute tag list, use them as target attribute tags, and extract the values ​​of the target attribute tags; (e.g., extract the "blade assembly") <sharpness>The "level" attribute value of the tag, the text content of the "" tag); if the attribute tags have a multi-level nested structure (such as... <material> <density> 5.0< / density> < / material> ), recursively enter <material>Node extraction <density>The value; The extracted equipment unique ID, component type, component unique ID, and target attribute tag values ​​are encapsulated into structured data (such as JSON objects or custom class instances) and stored in a shared result set (such as ConcurrentHashMap). 5) After all the independent threads have completed their tasks, the main thread merges the structured data stored in the shared result set from each independent thread and outputs it by equipment unique ID or component type (such as generating JSON files grouped by equipment or data tables statistically analyzed by component type), or directly passes it to downstream business modules (such as the equipment loading system of the game engine). Complete the customized multi-threaded analysis of the target equipment model.

[0014] In this embodiment, the parser is any one of a DOM parser, a SAX parser, or an XPath parser.

[0015] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.< / density> < / material> < / sharpness> < / equip> < / comp> < / equip> < / equip> < / comp> < / equip>

Claims

1. A customized multi-threaded parsing method for equipment models based on XML files, characterized in that, Includes the following steps: S1. Configure equipment XML files and XML parsing configuration files Place each equipment model in the equipment XML file, and define the start tag of each equipment model as <equiptype="equipment type" id="unique equipment ID">, and the rest are several <comp type="组件类型" id="组件唯一ID"> Tags, and custom attribute tags;< / comp> Write the equipment type of each equipment model, as well as the component type list and attribute tag list corresponding to the equipment type, into the XML parsing configuration file; S2. Construct the index table and mapping table. The XML parser parses the configuration file, constructs the mapping relationship between the equipment type of each equipment model and the corresponding component type list and attribute tag list, and generates an index table. A lightweight pre-scan of the equipment XML file is performed by a parser to establish a mapping table between the unique equipment ID of each equipment model and the node position of that equipment model in the equipment XML file. S3. Determine the target equipment model that needs to be analyzed; S4. Task Allocation and Recursive Analysis The parser performs a lightweight pre-scan of the equipment XML file, filters all node positions corresponding to the target equipment model, and encapsulates the equipment model corresponding to each node position into a parsing task. Each parsing task is submitted to a thread pool, which then assigns each parsing task to an independent thread within the pool. An independent thread extracts the equipment type and unique equipment ID from the equipment model in the parsing task using a parser. Traverse all component types under the equipment model, filter out the components that match the component type list, extract the component type and unique ID of the component by a separate thread, and use the component type corresponding to the component as the target component type; Recursively traverse all attribute tags under each target component type, filter out the attribute tags that match the attribute tag list, use them as target attribute tags, and extract the values ​​of the target attribute tags; The extracted equipment unique ID, component type, component unique ID, and target attribute tag values ​​are encapsulated into structured data and stored in a shared result set; S5. After all independent threads have completed their tasks, the main thread merges the structured data from each independent thread into a shared result set, and outputs it according to the equipment's unique ID or component type, thus completing the customized multi-threaded parsing of the target equipment model.

2. The method for customized multi-threaded parsing of equipment models based on XML files according to claim 1, characterized in that: In steps S2 and S4, the parser is any one of a DOM parser, a SAX parser, or an XPath parser.

3. The method for customized multi-threaded parsing of equipment models based on XML files according to claim 1, characterized in that: In step S4, the independent thread extracts the equipment type and unique equipment ID of the equipment model in the parsing task through the parser, and also needs to verify whether it is the target equipment model it is responsible for. If not, the corresponding parsing task will be reallocated by the thread pool.

4. The method for customized multi-threaded parsing of equipment models based on XML files according to claim 1, characterized in that: In step S4, the number of independent threads in the thread pool can be configured as needed, with the default being twice the number of CPU cores.

5. The method for customized multi-threaded parsing of equipment models based on XML files according to claim 1, characterized in that, Step S5 can also be: after all independent threads have completed their tasks, the main thread merges the structured data stored in the shared result set from each independent thread and directly transmits it to the downstream business module to complete the customized multi-threaded parsing of the target equipment model.