Xml file parsing method, system, computer and readable storage medium

By initializing the parsing engine and using the rule calculator to parse XML files and generate structured files, the problem of low parsing efficiency and high development cost caused by changes in XML file structure is solved, achieving efficient XML file parsing and multi-version compatibility.

CN115470374BActive Publication Date: 2025-11-07江西博微新技术有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211129451.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-16
Publication Date
2025-11-07
Estimated Expiration
2042-09-16

AI Technical Summary

Technical Problem

Existing technologies require pre-defined object models during XML file parsing, which need to be adjusted when the file structure changes. This results in low parsing efficiency and increased development costs, hindering widespread adoption.

Method used

By initializing the parsing engine, loading parsing configuration instructions, receiving XML file sets and parsing them into Document objects, using the rule calculator to calculate attribute values, and generating parsed structured files, it supports multi-version compatibility.

Benefits of technology

It enables the parsing of XML files with arbitrary structures, reduces system code maintenance costs, improves parsing efficiency, and is suitable for widespread deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115470374B_ABST
    Figure CN115470374B_ABST
Patent Text Reader

Abstract

The application provides an xml file parsing method, system, computer and readable storage medium, the method comprises the following steps: loading the parsing configuration instruction through the parsing engine; receiving the xml file set, and parsing each xml file in the xml file set through the parsing task flow to parse each xml file into the corresponding object respectively; reading the object into the context manager, and calling the corresponding rule calculator through the parsing configuration instruction; calculating the corresponding value of the object through reading the rule to calculate the attribute value corresponding to each xml file respectively; storing the attribute value in the context manager through the preset path, and making the context manager output the complete parsing structured file. Through the above method, the parsing of xml files with any structure can be realized, and the parsing efficiency of xml files is 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 data processing, in particular to an xml file parsing method and system, a computer and a readable storage medium. BACKGROUND

[0002] XML (Extensible Markup Language, Extensible Markup Language) is a standard general markup language, which has good extensibility, separation of content and form, strict syntax requirements, good value retention and other advantages, and has been widely used in people's daily work.

[0003] Among them, xml files have been widely used in various software systems, and existing xml files need to parse their file structures during use to further edit the files.

[0004] However, in the process of xml file parsing, the prior art needs to define the object model corresponding to the xml file in advance, and when the structure of the xml file changes, the current object model also needs to be changed accordingly, thereby reducing the xml file parsing efficiency, increasing the development cost of the xml file, and being not conducive to the wide promotion and use of the xml file. SUMMARY

[0005] Therefore, the purpose of the present application is to provide an xml file parsing method, system, computer and readable storage medium to solve the problem that the prior art needs to define the object model corresponding to the xml file in advance in the process of xml file parsing, and when the structure of the xml file changes, the current object model also needs to be changed accordingly, resulting in reduced xml file parsing efficiency.

[0006] The first aspect of the embodiment of the present application proposes an xml file parsing method, which comprises:

[0007] Initialize the parsing engine and load the parsing configuration instruction through the parsing engine, wherein the parsing configuration instruction comprises a parsing task flow;

[0008] Receive a set of xml files and parse each xml file in the set of xml files through the parsing task flow to parse each xml file into a corresponding Document object;

[0009] Read the Document object into a context manager and call a corresponding rule calculator through the parsing configuration instruction, wherein the rule calculator comprises a plurality of reading rules;

[0010] The Document objects are respectively calculated by the corresponding value calculation of the reading rules to calculate the attribute values corresponding to the xml files respectively;

[0011] The attribute values are respectively stored in the context manager through a preset path, and the context manager outputs the complete parsed structured file.

[0012] The beneficial effects of the present application are: firstly, the parsing engine is initialized, and the parsing configuration instruction is loaded by the parsing engine, wherein the parsing configuration instruction includes a parsing task flow; on this basis, the xml file set is received, and each xml file in the current xml file set is parsed by the above-mentioned parsing task flow to parse each xml file into a corresponding Document object; then the Document object is read into the context manager, and the corresponding rule calculator is called by the above-mentioned parsing configuration instruction, the rule calculator includes several reading rules; further, the Document object is respectively calculated by the corresponding value calculation of the current reading rules to calculate the attribute values corresponding to each xml file respectively; finally, only the current attribute values are respectively stored in the context manager through a preset path, and the context manager outputs the complete parsed structured file. Through the above-mentioned manner, the parsing of xml files with any structure can be realized, at the same time, the parsed data can be generated into a corresponding parsed structured file, and the parsing of xml files with multiple versions can be realized by condition filtering, thereby the cost of system code maintenance can be greatly reduced, the difficulty of system development is correspondingly reduced, and the parsing efficiency of xml files is improved, which is suitable for wide promotion and use.

[0013] Preferably, the parsing configuration instruction includes a dataSource attribute and a dataSourceType attribute, and the step of parsing each xml file in the xml file set by the parsing task flow to parse each xml file into a corresponding Document object includes:

[0014] When the xml file set is received, each xml file in the xml file set is identified, and the storage path and file format of each xml file in the disk are determined by the dataSource attribute and the dataSourceType attribute;

[0015] According to the storage path and the file format, each xml file is decrypted or decompressed to parse each xml file into a corresponding Document object.

[0016] Preferably, the parsing configuration instruction further comprises a filter attribute, and after the step of reading the Document object into the context manager, the method further comprises:

[0017] performing a Boolean operation on the filter attribute through an MVEL expression engine to perform filtering processing on the Document object.

[0018] Preferably, the parsing configuration instruction further comprises an execRule attribute, and the step of invoking the corresponding rule calculator through the parsing configuration instruction comprises:

[0019] invoking the execRule attribute in the parsing configuration instruction, and invoking the rule calculator through a preset reflection method based on the execRule attribute.

[0020] Preferably, the parsing configuration instruction further comprises a toData attribute, and the step of storing the attribute values through a preset path into the context manager respectively comprises:

[0021] setting the toData attribute as a data storage path, and storing the attribute values into the context manager through the toData attribute.

[0022] The second aspect of the embodiment of the present application proposes an xml file parsing system, the system comprises:

[0023] a loading module, configured to initialize a parsing engine, and load a parsing configuration instruction through the parsing engine, the parsing configuration instruction comprising a parsing task flow;

[0024] a parsing module, configured to receive a set of xml files, and perform parsing processing on each xml file in the set of xml files through the parsing task flow, so as to parse each xml file into a corresponding Document object;

[0025] a reading module, configured to read the Document object into a context manager, and invoke a corresponding rule calculator through the parsing configuration instruction, the rule calculator comprising a plurality of reading rules;

[0026] a calculation module, configured to perform corresponding value calculation on the Document object through the plurality of reading rules respectively, so as to calculate a plurality of attribute values corresponding to each xml file respectively;

[0027] An output module is configured to store the attribute values in the context manager through a preset path respectively, and make the context manager output a complete parsed structured file.

[0028] In the xml file parsing system, the parsing configuration instruction includes a dataSource attribute and a dataSourceType attribute, and the parsing module is specifically configured to:

[0029] When the xml file set is received, each xml file in the xml file set is identified, and the storage path and the file format of each xml file in the disk are determined through the dataSource attribute and the dataSourceType attribute;

[0030] Each xml file is decrypted or decompressed according to the storage path and the file format, so as to parse each xml file into a corresponding Document object.

[0031] In the xml file parsing system, the parsing configuration instruction further includes a filter attribute, and the xml file parsing system further includes a filtering module, and the filtering module is specifically configured to:

[0032] The filter attribute is subjected to Boolean operation through an MVEL expression engine, so as to filter the Document object.

[0033] In the xml file parsing system, the parsing configuration instruction further includes an execRule attribute, and the reading module is specifically configured to:

[0034] The execRule attribute in the parsing configuration instruction is called, and the rule calculator is called through a preset reflection method based on the execRule attribute.

[0035] In the xml file parsing system, the parsing configuration instruction further includes a toData attribute, and the output module is specifically configured to:

[0036] The toData attribute is set as a data storage path, and the attribute values are stored in the context manager through the toData attribute.

[0037] The third aspect of the embodiment of the present application provides a computer including a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the xml file parsing method as described above when executing the computer program.

[0038] The fourth aspect of the embodiment of the present application provides a readable storage medium, which has a computer program stored thereon, and the program is executed by a processor to realize the xml file parsing method as described above.

[0039] Additional aspects and advantages of the present application will be described in the description that follows, and will become apparent from the description, or can be learned by practice of the present application. BRIEF DESCRIPTION OF DRAWINGS

[0040] Figure 1 A flow chart of the xml file parsing method provided by the first embodiment of the present application is shown in the figure.

[0041] Figure 2 A structural block diagram of the xml file parsing system provided by the second embodiment of the present application is shown in the figure.

[0042] The following detailed description will further describe the present application with reference to the above-mentioned figures. DETAILED DESCRIPTION

[0043] In order to facilitate the understanding of the present application, the present application will be described more fully below with reference to the accompanying drawings. The figures show several embodiments of the present application. However, the present application can be realized in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0044] It should be noted that when an element is referred to as being "fixed to" another element, it can be directly on the other element or there can be a middle element. When an element is referred to as being "connected" to another element, it can be directly connected to the other element or there can be a middle element. The terms "vertical", "horizontal", "left", "right", and similar expressions used herein are for illustrative purposes only.

[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terminology used in the description of the present application herein only for the purpose of describing specific embodiments and is not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the associated listed items.

[0046] In the prior art, the object model corresponding to the xml file needs to be defined in advance in the process of xml file parsing. When the structure of the xml file changes, the current object model also needs to be changed accordingly, thereby reducing the parsing efficiency of the xml file, increasing the development cost of the xml file, and being not conducive to the wide promotion and use of the xml file.

[0047] Please refer toFigure 1 The xml file parsing method provided by the first embodiment of the present application can realize parsing of xml files of any structure, and at the same time, can generate corresponding parsed structured files from parsed data, and can realize parsing of xml files of multiple versions through conditional filtering, thereby greatly reducing the cost of system code maintenance, reducing the difficulty of system development, and improving the parsing efficiency of xml files, and is suitable for wide promotion and use.

[0048] Specifically, the xml file parsing method provided by the embodiment specifically includes the following steps:

[0049] Step S10, initializing the parsing engine, and loading the parsing configuration instruction through the parsing engine, wherein the parsing configuration instruction includes a parsing task flow;

[0050] Specifically, in the embodiment, first of all, it needs to be pointed out that the xml file parsing method provided by the embodiment is specifically applied to various xml files, and can process one or more xml files at the same time, for improving the parsing efficiency of xml files.

[0051] In addition, in the embodiment, it needs to be pointed out that the xml file parsing method provided by the embodiment is specifically implemented based on a parsing server arranged in the background, and the parsing server specifically includes a task scheduler, a context manager, a variable processor and a rule calculator.

[0052] Therefore, in this step, it needs to be pointed out that the above-mentioned parsing server first initializes the internal parsing engine, and on this basis, loads the required parsing configuration instruction through the parsing engine, wherein it needs to be pointed out that the parsing configuration instruction includes a parsing task flow which has been constructed, and specifically, the parsing task flow is used for parsing the received xml file.

[0053] Preferably, in the embodiment, the parsing task flow provided by the embodiment can include file reading, conditional filtering, path value taking, rule calculation, output definition and task association.

[0054] It also needs to be pointed out that the parsing engine provided by the embodiment is built-in with a variable processor, and in the actual working process, the parsing engine provided by the embodiment can store the process data of task execution into the above-mentioned variable processor as a temporary variable using the tempPath attribute in the parsing configuration as a data path; if the variable is needed to be used, the corresponding variable data can be obtained by naming it as ${variable name} in the attribute value in the above-mentioned parsing engine.

[0055] Step S20, receiving the xml file set, and parsing each xml file in the xml file set through the parsing task flow to parse each xml file into a corresponding Document object respectively;

[0056] Further, in this step, it needs to be pointed out that after loading the parsing configuration instruction through the above steps, this step will receive the xml file set input by the external program through the above task scheduler, on this basis, this step will further parse each xml file in the current input xml file set based on the task scheduler through the above loaded parsing task flow, to correspond to parse each xml file into the required Document (document) object, so as to process each xml file in the subsequent step.

[0057] Among them, it needs to be pointed out that the Document object disclosed in this embodiment is a computer code, which can improve the processing efficiency of the subsequent computer.

[0058] Among them, in this step, it needs to be pointed out that the parsing configuration instruction includes the dataSource attribute and the dataSourceType attribute, and the step of parsing each xml file in the xml file set through the parsing task flow to parse each xml file into a corresponding Document object includes:

[0059] When receiving the xml file set, identifying each xml file in the xml file set, and determining the storage path and file format of each xml file in the disk through the dataSource attribute and the dataSourceType attribute;

[0060] According to the storage path and the file format, each xml file is decrypted or decompressed to parse each xml file into a corresponding Document object.

[0061] Among them, it needs to be pointed out that after the task scheduler receives the xml file set, the current task scheduler will further identify each individual xml file in the current xml file set, on this basis, through the dataSource attribute and the dataSourceType attribute in the above parsing configuration instruction, the storage path and file format of each xml file in the disk are determined, so that the type of each xml file can be correspondingly obtained.

[0062] Step S30, the Document object is read into the context manager, and the corresponding rule calculator is called through the parsing configuration instruction, the rule calculator includes several reading rules;

[0063] Specifically, in this step, it needs to be pointed out that after parsing each xml file into the corresponding Document object, this step will further read the above-mentioned Document object into the above-mentioned context manager, at the same time, the corresponding rule calculator will also be called through the above-mentioned parsing configuration instruction, it needs to be pointed out that the rule calculator includes several reading rules which have been preset.

[0064] Preferably, in this embodiment, the several reading rules provided by this embodiment can include: engine built-in rules, such as tree structure reading rules, list structure reading rules, object structure reading rules, string structure reading rules, and basic mathematical operation rules, etc. In the process of actual work, each reading rule can correspond to reading the xml file adapted to it, so as to meet the reading requirements of various xml files and improve the parsing efficiency of xml files.

[0065] Among them, in this step, it needs to be pointed out that the parsing configuration instruction also includes a filter attribute, after the step of reading the Document object into the context manager, the method further includes:

[0066] The filter (conditional filtering) attribute is subjected to Boolean operation through the MVEL expression engine, so as to filter the Document object.

[0067] It needs to be pointed out that after this embodiment reads the above-mentioned Document object into the above-mentioned context manager, this step will further subject the filter (conditional filtering) attribute in the above-mentioned parsing configuration instruction to Boolean operation through the preset MVEL expression engine, so as to filter the current Document object, so as to be able to remove the defect files in each Document object.

[0068] In addition, in this step, it also needs to be pointed out that the parsing configuration instruction also includes an execRule (execute rule) attribute, the step of calling the corresponding rule calculator through the parsing configuration instruction includes:

[0069] The execRule attribute in the parsing configuration instruction is called, and the rule calculator is called through the preset reflection method based on the execRule attribute.

[0070] Specifically, it needs to be explained that after the filtering process of each Document object is completed, the step will further call the rule calculator according to the execRule attribute in the above-mentioned parsing configuration instruction and the preset reflection method, so as to correspondingly improve the processing efficiency.

[0071] Step S40, a corresponding value calculation is performed on the Document object by a plurality of reading rules to calculate a plurality of attribute values corresponding to each xml file respectively.

[0072] Further, it needs to be explained that after the Document object and the corresponding reading rule are obtained respectively through the above-mentioned steps, the step will further perform a corresponding value calculation on the current plurality of Document objects by the current plurality of reading rules, so as to finally calculate a plurality of attribute values corresponding to the current xml files respectively. It needs to be pointed out that the plurality of attribute values can correspond to the quantification of each xml file, so as to facilitate subsequent processing.

[0073] Step S50, a plurality of attribute values are stored in the context manager through a preset path respectively, and the context manager outputs a complete parsed structured file.

[0074] Finally, it needs to be explained that after the attribute values corresponding to the current plurality of xml files are obtained respectively through the above-mentioned steps, the step will further store the current plurality of attribute values in the above-mentioned context manager through a preset path respectively, and finally make the current context manager output a complete parsed structured file.

[0075] In this step, it needs to be pointed out that the parsing configuration instruction further includes a toData (data output location) attribute, and the step of storing a plurality of attribute values in the context manager through a preset path includes:

[0076] The toData attribute is set as a data storage path, and a plurality of attribute values are stored in the context manager through the toData attribute.

[0077] Specifically, after the required attribute values are finally obtained through the above-mentioned steps, the step will further store the current plurality of attribute values in the above-mentioned context manager through the toData attribute in the above-mentioned parsing configuration instruction.

[0078] In use, by first initializing the parsing engine, and loading the parsing configuration instruction through the parsing engine, wherein the parsing configuration instruction includes a parsing task flow; on this basis, the xml file set is received, and each xml file in the current xml file set is parsed through the above-mentioned parsing task flow to parse each xml file into a corresponding Document object; then the Document object is read into the context manager, and the corresponding rule calculator is called through the above-mentioned parsing configuration instruction, the rule calculator includes a plurality of reading rules; further, the above-mentioned Document object is respectively calculated through the current plurality of reading rules to calculate a plurality of attribute values corresponding to each xml file; finally, only the current plurality of attribute values are stored in the above-mentioned context manager through a preset path, and the above-mentioned context manager outputs a complete parsing structured file. Through the above-mentioned manner, the parsing of xml files of any structure can be realized, at the same time, the parsed data can be generated into a corresponding parsing structured file, and the parsing of xml files of multiple versions can be realized through conditional filtering, so that the cost of system code maintenance can be greatly reduced, the difficulty of system development is correspondingly reduced, and the parsing efficiency of xml files is improved, which is suitable for wide promotion and use.

[0079] It should be noted that the above implementation process is only to illustrate the feasibility of the present application, but it does not mean that the xml file parsing method of the present application has only the above-mentioned unique implementation process, on the contrary, as long as the xml file parsing method of the present application can be implemented, it can be included in the feasible implementation scheme of the present application.

[0080] In summary, the xml file parsing method provided by the above-mentioned embodiment of the present application can realize the parsing of xml files of any structure, at the same time, the parsed data can be generated into a corresponding parsing structured file, and the parsing of xml files of multiple versions can be realized through conditional filtering, so that the cost of system code maintenance can be greatly reduced, the difficulty of system development is correspondingly reduced, and the parsing efficiency of xml files is improved, which is suitable for wide promotion and use.

[0081] Please refer to Figure 2 , which is an xml file parsing system provided by the second embodiment of the present application, the system includes:

[0082] The loading module 12 is used for initializing the parsing engine, and loading the parsing configuration instruction through the parsing engine, wherein the parsing configuration instruction includes a parsing task flow;

[0083] The parsing module 22 is configured to receive the set of XML files and parse each XML file in the set of XML files through the parsing task flow to parse each XML file into a corresponding Document object.

[0084] The reading module 32 is configured to read the Document object into a context manager and invoke a corresponding rule calculator through the parsing configuration instruction, the rule calculator including a plurality of reading rules.

[0085] The calculation module 42 is configured to perform corresponding value calculation on the Document object through the plurality of reading rules to calculate a plurality of attribute values corresponding to each XML file.

[0086] The output module 52 is configured to store the plurality of attribute values in the context manager through a preset path and cause the context manager to output a complete parsed structured file.

[0087] In the XML file parsing system, the parsing configuration instruction includes a dataSource attribute and a dataSourceType attribute, and the parsing module 22 is specifically configured to:

[0088] When the set of XML files is received, each XML file in the set of XML files is identified, and the storage path and the file format of each XML file in the disk are determined through the dataSource attribute and the dataSourceType attribute.

[0089] Each XML file is decrypted or decompressed according to the storage path and the file format to parse each XML file into a corresponding Document object.

[0090] In the XML file parsing system, the parsing configuration instruction further includes a filter attribute, and the XML file parsing system further includes a filtering module 62, and the filtering module 62 is specifically configured to:

[0091] The filter attribute is subjected to Boolean operation through an MVEL expression engine to filter the Document object.

[0092] In the XML file parsing system, the parsing configuration instruction further includes an execRule attribute, and the reading module 32 is specifically configured to:

[0093] The execRule attribute in the parsing configuration instruction is called, and the rule calculator is called based on the execRule attribute through a preset reflection method.

[0094] In the xml file parsing system, the parsing configuration instruction further includes a toData attribute, and the output module 52 is specifically configured to:

[0095] The toData attribute is set as a data storage path, and a plurality of attribute values are stored in the context manager through the toData attribute.

[0096] The third embodiment of the present application provides a computer, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the xml file parsing method provided in the first embodiment when executing the computer program.

[0097] The fourth embodiment of the present application provides a readable storage medium, which stores a computer program executable by a processor, and the computer program implements the xml file parsing method provided in the first embodiment when executed by the processor.

[0098] In summary, the xml file parsing method, system, computer and readable storage medium provided in the above embodiments can realize the parsing of xml files with any structure, and at the same time, can generate corresponding parsed structured files from parsed data, and can realize the parsing of xml files of multiple versions through conditional filtering, thereby greatly reducing the cost of system code maintenance, reducing the difficulty of system development, improving the parsing efficiency of xml files, and being suitable for wide promotion and use.

[0099] It should be noted that the above-mentioned modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above-mentioned modules can be located in the same processor, or the above-mentioned modules can be located in different processors in any combination.

[0100] The logic and / or steps represented in the flowcharts and / or described herein, for example, can be embodied in non-transitory computer-readable media, executed by one or more computing devices, and / or in any other way. The logic and / or steps represented in the flowcharts and / or described herein, for example, can be considered a list of executable instructions for implementing logic functions, and can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor- containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection (electronic) having one or more wires, a portable computer diskette (magnetic), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber (optical), and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, for example via an optical scanner, then compiled, interpreted, or otherwise processed, and stored in a computer memory in a form that can be later executed by a computer. In this context, a "computer-readable medium" can be any means that can store the program for use by or in connection with the instruction execution system, apparatus, or device.

[0101] The foregoing description of various embodiments of the application has been presented for the purposes of illustration and description. It is not intended to be exhaustive or to limit the application to the precise form disclosed, and various modifications and variations are possible in light of the above teachings. It is intended that the scope of the application be limited not with this detailed description, but rather by the claims appended hereto.

[0102] It is understood that various portions of the application can be implemented in hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, and in another embodiment, any of the following technologies known in the art, or a combination thereof, can be used: discrete logic circuitry having logic gates for implementing logic functions upon an application of data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), and the like.

[0103] In the description of the present specification, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Also, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in one or more embodiments or examples.

[0104] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be noted that for ordinary skilled persons in the art, without departing from the concept of the present application, several modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.

Claims

1. An XML file parsing method, characterized by, The method comprises: initializing a parsing engine, and loading a parsing configuration instruction through the parsing engine, the parsing configuration instruction comprising a parsing task flow; receiving a set of xml files, and parsing each xml file in the set of xml files through the parsing task flow to parse each xml file into a corresponding Document object; reading the Document object into a context manager, and invoking a corresponding rule calculator through the parsing configuration instruction, the rule calculator comprising a plurality of reading rules; performing corresponding value calculation on the Document object through the plurality of reading rules to calculate a plurality of attribute values corresponding to each xml file; storing the plurality of attribute values in the context manager through a preset path, and causing the context manager to output a complete parsed structured file; the parsing configuration instruction comprises a dataSource attribute and a dataSourceType attribute, and the parsing each xml file in the set of xml files through the parsing task flow to parse each xml file into a corresponding Document object comprises: when the set of xml files is received, identifying each xml file in the set of xml files, and determining the storage path and file format of each xml file in the disk through the dataSource attribute and the dataSourceType attribute; decrypting or decompressing each xml file according to the storage path and the file format to parse each xml file into a corresponding Document object; the parsing configuration instruction further comprises a filter attribute, and after the step of reading the Document object into the context manager, the method further comprises: performing Boolean operation on the filter attribute through an MVEL expression engine to filter the Document object; the parsing configuration instruction further comprises an execRule attribute, and the step of invoking the corresponding rule calculator through the parsing configuration instruction comprises: invoking the execRule attribute in the parsing configuration instruction, and invoking the rule calculator through a preset reflection method based on the execRule attribute; the parsing configuration instruction further comprises a toData attribute, and the step of storing the plurality of attribute values in the context manager through a preset path comprises: setting the toData attribute as a data storage path, and storing the plurality of attribute values in the context manager through the toData attribute.

2. An XML file parsing system, characterized by, The system comprises: a loading module configured to initialize a parsing engine, and load a parsing configuration instruction through the parsing engine, the parsing configuration instruction comprising a parsing task flow; The parsing module is configured to receive a set of XML files and parse each XML file in the set of XML files through the parsing task flow to parse each XML file into a corresponding Document object; The reading module is configured to read the Document object into a context manager and invoke a corresponding rule calculator through the parsing configuration instruction, the rule calculator including a plurality of reading rules; The calculation module is configured to perform corresponding value calculation on the Document object through the plurality of reading rules to calculate a plurality of attribute values corresponding to each XML file; The output module is configured to store the plurality of attribute values in the context manager through a preset path and cause the context manager to output a complete parsed structured file; The parsing configuration instruction includes a dataSource attribute and a dataSourceType attribute, and the parsing module is specifically configured to: When the set of XML files is received, identify each XML file in the set of XML files, and determine the storage path and file format of each XML file in the disk through the dataSource attribute and the dataSourceType attribute; Decrypt or decompress each XML file according to the storage path and file format to parse each XML file into a corresponding Document object; The parsing configuration instruction further includes a filter attribute, and the XML file parsing system further includes a filtering module, and the filtering module is specifically configured to: Perform Boolean operation on the filter attribute through an MVEL expression engine to filter the Document object; The parsing configuration instruction further includes an execRule attribute, and the reading module is specifically configured to: Invoke the execRule attribute in the parsing configuration instruction and invoke the rule calculator through a preset reflection method based on the execRule attribute; The parsing configuration instruction further includes a toData attribute, and the output module is specifically configured to: Set the toData attribute as a data storage path and store the plurality of attribute values in the context manager through the toData attribute.

3. A computer comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the XML file parsing method of claim 1.

4. A readable storage medium, having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the XML file parsing method of claim 1.

Citation Information

Patent Citations

  • Method and system for converting xml into excel suitable for testlink

    CN111177074A

  • Batch file processing method and device, electronic equipment and storage medium

    CN112925752A

  • XML Streaming Parsing with DOM Instances

    US20100083099A1