CN107038148A - The analytic method and resolver of XML document - Google Patents

The analytic method and resolver of XML document Download PDF

Info

Publication number
CN107038148A
CN107038148A CN201710279835.9A CN201710279835A CN107038148A CN 107038148 A CN107038148 A CN 107038148A CN 201710279835 A CN201710279835 A CN 201710279835A CN 107038148 A CN107038148 A CN 107038148A
Authority
CN
China
Prior art keywords
xml document
node
nodes
specified node
specified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710279835.9A
Other languages
Chinese (zh)
Inventor
赵睿
范立波
陈皓
刘冬娜
朱延超
陈懿
魏海健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Elephant Hui Yun Information Technology Co Ltd
Original Assignee
Elephant Hui Yun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Elephant Hui Yun Information Technology Co Ltd filed Critical Elephant Hui Yun Information Technology Co Ltd
Priority to CN201710279835.9A priority Critical patent/CN107038148A/en
Publication of CN107038148A publication Critical patent/CN107038148A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation

Abstract

The present invention relates to a kind of analytic method of XML document and resolver, the analytic method comprises the following steps:XML document to be resolved is obtained, and obtains the information for specifying node;The XML document is parsed, all nodes in the XML document are obtained;The specified node is matched in all nodes, and obtains the related data of the specified node;Corresponding Map interfaces are generated according to the related data of the specified node.Technical scheme can realize the conversion between XML document and Map interfaces automatically, reduce the code development pressure and intensity of programming personnel, be conducive to improving the development efficiency of product.

Description

The analytic method and resolver of XML document
Technical field
The present invention relates to field of computer technology, and in particular to the analytic method and resolver of a kind of XML document.
Background technology
The increased popularity developed with web, data interaction also all the more important.The either friendship between front-end and back-end Mutually, the interaction or between client and server, XOR is the interaction that interaction between different server all embodies data.
And the essence of network is exactly the topological structure for transmitting mutually between a data, changing mutually, interacting.In order to Solve to form two kinds of specifications gradually between the problem of transmission between data, the world:A kind of is the transmission side based on additional character Formula, such as JSON (JavaScript Object Notation, a kind of data interchange format of lightweight);Another is to be based on one The transfer mode for the formula that fixes, such as XML (Extensible Markup Language, extending mark language).JSON is present still It is simply popular in web terminal, and XML occupies the share of huge data interaction always.
In addition, Map interfaces are needed through commonly used in programming process, its store paired key-value object there is provided Key (key) arrives value (value) mapping), it can realize and value is quickly searched according to key.
But, the conversion method between XML and Map is not provided but at present, programmer oneself is then needed according to current Service message write conversion method, but relatively low use scope and recycling rate of waterused become data interaction above this A comparison it is awkward the problem of.
It should be noted that information is only used for strengthening the reason of the background to the present invention disclosed in above-mentioned background section Solution, therefore can include not constituting the information to prior art known to persons of ordinary skill in the art.
The content of the invention
It is an object of the invention to provide a kind of parsing scheme of XML document, so at least overcome to a certain extent by One or more problem caused by the limitation of correlation technique and defect.
Other characteristics and advantage of the present invention will be apparent from by following detailed description, or partially by the present invention Practice and acquistion.
According to an aspect of the invention, there is provided a kind of analytic method of XML document, comprises the following steps:Acquisition is treated The XML document of parsing, and obtain the information for specifying node;The XML document is parsed, obtains all in the XML document Node;The specified node is matched in all nodes, and obtains the related data of the specified node;Referred to according to described The related data for determining node generates corresponding Map interfaces.
In some embodiments of the invention, based on aforementioned schemes, the XML document is parsed, is obtained in the XML document All nodes the step of, including:The XML document is parsed, the root node in the XML document is obtained;Based on described section Point, circulation obtains all nodes in the XML document.
In some embodiments of the invention, based on aforementioned schemes, in addition to:All sections in the XML document Point, generates the node listing of the XML document;The step of specified node being matched in all nodes, including:Institute State and the specified node is matched in node listing.
In some embodiments of the invention, based on aforementioned schemes, the related data of the specified node includes:It is described to refer to Determine the title of node and the content of the specified node.
In some embodiments of the invention, based on aforementioned schemes, according to the generation pair of the related data of the specified node The step of Map interfaces answered, including:The name of the specified node is referred to as to the key of the Map interfaces, and specified described The content of node as the Map interfaces value, to generate the Map interfaces.
In some embodiments of the invention, based on aforementioned schemes, the XML document is parsed by dom4j instruments, obtained All nodes in the XML document.
According to another aspect of the present invention, a kind of resolver of XML document is additionally provided, including:First acquisition unit, The XML document to be resolved for obtaining, and obtain the information for specifying node;Resolution unit, for parsing the XML document, Obtain all nodes in the XML document;Second acquisition unit, for matching the specified section in all nodes Point, and obtain the related data of the specified node;Generation unit, for according to the generation pair of the related data of the specified node The Map interfaces answered.
In some embodiments of the invention, based on aforementioned schemes, the resolution unit is configured to:Parse the XML texts Shelves, obtain the root node in the XML document;Based on the root node, circulation obtains all nodes in the XML document.
In some embodiments of the invention, based on aforementioned schemes, the resolution unit is additionally configured to:According to the XML All nodes in document, generate the node listing of the XML document;The second acquisition unit is configured to:In the node The specified node is matched in list.
In some embodiments of the invention, based on aforementioned schemes, the related data of the specified node includes:It is described to refer to Determine the title of node and the content of the specified node.
In some embodiments of the invention, based on aforementioned schemes, the generation unit is configured to:By the specified node Name be referred to as the key of the Map interfaces, and using the content of the specified node as the Map interfaces value, with life Into the Map interfaces.
In the technical scheme that some embodiments of the present invention are provided, by providing between XML document and Map interfaces Conversion plan so that, can be based on the Map interfaces being converted to, directly according to section when needing to obtain the attribute of some node The title of point searches the content of node, rapidly realizes the acquisition process of data, and then cause programming personnel without being concerned about How data conversion is carried out, alleviate the code development pressure of programming personnel, be conducive to improving the development efficiency of product.
Brief description of the drawings
Fig. 1 diagrammatically illustrates the flow chart of the analytic method of XML document according to first embodiment of the invention;
Fig. 2 diagrammatically illustrates the flow chart that XML document according to an embodiment of the invention is converted to Map;
Fig. 3 diagrammatically illustrates the flow chart of the analytic method of the XML document of second embodiment according to the present invention;
Fig. 4 diagrammatically illustrates the block diagram of the resolver of XML document according to an embodiment of the invention.
Embodiment
Example embodiment is described more fully with referring now to accompanying drawing.However, example embodiment can be with a variety of shapes Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the present invention will more Fully and completely, and by the design of example embodiment those skilled in the art is comprehensively conveyed to.
Implement in addition, described feature, structure or characteristic can be combined in any suitable manner one or more In example.Embodiments of the invention are fully understood so as to provide there is provided many details in the following description.However, It will be appreciated by persons skilled in the art that technical scheme can be put into practice without one or more in specific detail, Or can be using other methods, constituent element, device, step etc..In other cases, it is not shown in detail or describes known side Method, device, realization operate to avoid fuzzy each aspect of the present invention.
Block diagram shown in accompanying drawing is only functional entity, not necessarily must be corresponding with physically separate entity. I.e., it is possible to realize these functional entitys using software form, or realized in one or more hardware modules or integrated circuit These functional entitys, or realize in heterogeneous networks and/or processor device and/or microcontroller device these functional entitys.
Flow chart shown in accompanying drawing is merely illustrative, it is not necessary to including all contents and operation/step, It is not required to perform by described order.For example, some operation/steps can also be decomposed, and some operation/steps can be closed And or part merge, therefore the actual order performed is possible to be changed according to actual conditions.
Fig. 1 diagrammatically illustrates the flow chart of the analytic method of XML document according to first embodiment of the invention.
Reference picture 1, the analytic method of XML document according to first embodiment of the invention, comprises the following steps:
Step S10, obtains XML document to be resolved, and obtain the information for specifying node.
In this embodiment, specify the number of node and be not especially limited, in other words, specify the number of node both may be used To be one or multiple.Specify the information of node to be required to be identified the node, such as can be the node Title.
Step S12, parses the XML document, obtains all nodes in the XML document.
According to the exemplary embodiment of the present invention, step S12 includes:The XML document is parsed, the XML document is obtained In root node;Based on the root node, circulation obtains all nodes in the XML document.
More specifically, the XML document can be parsed by dom4j (being that the XML increased income a parsing is wrapped) instrument, obtain All nodes in the XML document.
After all nodes of XML document are obtained, the node listing of XML document can be generated, so can be in order to rear Continue and corresponding node is searched in node listing.
Step S14, matches the specified node, and obtain the dependency number of the specified node in all nodes According to.
In an embodiment of the present invention, the related data of node is specified to include:The title and the finger of the specified node Determine the content of node.
Wherein, if the node in XML document is stored by the form of node listing, then step S14 is specific Including:The specified node is matched in the node listing.By using node listing, of node can be rapidly realized With process.
Step S16, corresponding Map interfaces are generated according to the related data of the specified node.
According to the exemplary embodiment of the present invention, step S16 includes:The name of the specified node is referred to as the Map The key of interface, and using the content of the specified node as the Map interfaces value, to generate the Map interfaces.
To sum up, as shown in Fig. 2 the scheme of the embodiment of the present invention can be parsed to XML document and be converted to Map automatically Interface, dramatically reduces the code development pressure of programming personnel.
Specifically, can be by XML node, layer by layer toward assignment in Map when needing XML resolving to Map, wherein XML sections The entitled Map of point key, the content of XML node is Map value;Finally by the innermost key-value key-value pairs of Map It is recycled to outermost.If there is repeat key, then its corresponding value be converted to list modes and stored.It is final to need When taking some attribute, it can find the content of the node of needs directly according to the title of node, quickly finish needs Data acquisition.Idiographic flow can refer to Fig. 3.
As shown in figure 3, according to the analytic method of the XML document of second embodiment of the present invention, including:
Step S302, obtains XML document and the parameter needed.It should be noted that the parameter needed is given section The title of the relevant information of point, such as given node.
Step S304, the XML document is parsed using dom4j, obtains top element.Wherein, top element is root node.
Step S306, circulation obtains all elements (obtaining all nodes), is put into list set.
Step S308, travels through the parameter needed, and corresponding node is matched in list set.I.e. according to given node Relevant information matches corresponding node in list set.
Step S310, obtains the data of the node matched.
Step S312, is put into set as output.
Step S314, returning result Map.Wherein, the entitled Map of XML node key, the content of XML node is Map Value.
Fig. 4 diagrammatically illustrates the block diagram of the resolver of XML document according to an embodiment of the invention.
As shown in figure 4, the resolver 400 of XML document according to an embodiment of the invention, including:First acquisition unit 402nd, resolution unit 404, second acquisition unit 406 and generation unit 408.
Specifically, first acquisition unit 402 is used to obtain XML document to be resolved, and obtains the information for specifying node; Resolution unit 404 is used to parse the XML document, obtains all nodes in the XML document;Second acquisition unit 406 is used In matching the specified node in all nodes, and obtain the related data of the specified node;Generation unit 408 is used According to the corresponding Map interfaces of the related data of specified node generation.
In some embodiments of the invention, based on aforementioned schemes, the resolution unit 404 is configured to:Parse the XML Document, obtains the root node in the XML document;Based on the root node, circulation obtains all sections in the XML document Point.
In some embodiments of the invention, based on aforementioned schemes, the resolution unit 404 is additionally configured to:According to described All nodes in XML document, generate the node listing of the XML document;The second acquisition unit 406 is configured to:Institute State and the specified node is matched in node listing.
In some embodiments of the invention, based on aforementioned schemes, the related data of the specified node includes:It is described to refer to Determine the title of node and the content of the specified node.
In some embodiments of the invention, based on aforementioned schemes, the generation unit 408 is configured to:Specified described The name of node is referred to as the key of the Map interfaces, and using the content of the specified node as the Map interfaces value, To generate the Map interfaces.
The XML that the above embodiment of the present invention is provided resolves to Map scheme, can provide to the quick of small-sized XML file Parsing, if carrying out data conversion without being concerned about, allows programmer to focus more on the lifting of technology and the logic of business.Together When solve and only need the low volume data of XML document, but the problem of need assembled XML document corresponding whole object, effectively The establishment of protocol object is reduced, mitigates programmer's code development pressure and intensity.
Although it should be noted that being referred to some modules or list of the equipment for action executing in above-detailed Member, but this division is not enforceable.In fact, according to the embodiment of the present invention, it is above-described two or more Module or the feature and function of unit can embody in a module or unit.Conversely, an above-described mould The feature and function of block or unit can be further divided into being embodied by multiple modules or unit.
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented Mode can be realized by software, can also be realized by way of software combines necessary hardware.Therefore, according to the present invention The technical scheme of embodiment can be embodied in the form of software product, the software product can be stored in one it is non-volatile Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are to cause a calculating Equipment (can be personal computer, server, touch control terminal or network equipment etc.) is performed according to embodiment of the present invention Method.
Those skilled in the art will readily occur to its of the present invention after considering specification and putting into practice invention disclosed herein Its embodiment.The application be intended to the present invention any modification, purposes or adaptations, these modifications, purposes or Person's adaptations follow the general principle of the present invention and including undocumented common knowledge in the art of the invention Or conventional techniques.Description and embodiments are considered only as exemplary, and true scope and spirit of the invention are by following Claim is pointed out.
It should be appreciated that the invention is not limited in the precision architecture for being described above and being shown in the drawings, and And various modifications and changes can be being carried out without departing from the scope.The scope of the present invention is only limited by appended claim.

Claims (11)

1. a kind of analytic method of XML document, comprises the following steps:
XML document to be resolved is obtained, and obtains the information for specifying node;
The XML document is parsed, all nodes in the XML document are obtained;
The specified node is matched in all nodes, and obtains the related data of the specified node;
Corresponding Map interfaces are generated according to the related data of the specified node.
2. the analytic method of XML document as claimed in claim 1, wherein, the XML document is parsed, the XML document is obtained In all nodes the step of, including:
The XML document is parsed, the root node in the XML document is obtained;
Based on the root node, circulation obtains all nodes in the XML document.
3. the analytic method of XML document as claimed in claim 1, in addition to:All nodes in the XML document, Generate the node listing of the XML document;
The step of specified node being matched in all nodes, including:Described specify is matched in the node listing Node.
4. the analytic method of XML document as claimed in claim 1, wherein, the related data of the specified node includes:It is described Specify the title of node and the content of the specified node.
5. the analytic method of XML document as claimed in claim 4, wherein, generated according to the related data of the specified node The step of corresponding Map interfaces, including:
The name of the specified node is referred to as to the key of the Map interfaces, and using the content of the specified node as described The value of Map interfaces, to generate the Map interfaces.
6. the analytic method of the XML document as any one of claim 1 to 5, wherein, institute is parsed by dom4j instruments XML document is stated, all nodes in the XML document are obtained.
7. a kind of resolver of XML document, including:
First acquisition unit, the XML document to be resolved for obtaining, and obtain the information for specifying node;
Resolution unit, for parsing the XML document, obtains all nodes in the XML document;
Second acquisition unit, for matching the specified node in all nodes, and obtains the phase of the specified node Close data;
Generation unit, for generating corresponding Map interfaces according to the related data of the specified node.
8. the resolver of XML document as claimed in claim 7, wherein, the resolution unit is configured to:
The XML document is parsed, the root node in the XML document is obtained;
Based on the root node, circulation obtains all nodes in the XML document.
9. the resolver of XML document as claimed in claim 7, wherein, the resolution unit is additionally configured to:
All nodes in the XML document, generate the node listing of the XML document;
The second acquisition unit is configured to:The specified node is matched in the node listing.
10. the resolver of the XML document as any one of claim 7 to 9, wherein, the correlation of the specified node Data include:The content of the title of the specified node and the specified node.
11. the resolver of XML document as claimed in claim 10, wherein, the generation unit is configured to:
The name of the specified node is referred to as to the key of the Map interfaces, and using the content of the specified node as described The value of Map interfaces, to generate the Map interfaces.
CN201710279835.9A 2017-04-25 2017-04-25 The analytic method and resolver of XML document Pending CN107038148A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710279835.9A CN107038148A (en) 2017-04-25 2017-04-25 The analytic method and resolver of XML document

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710279835.9A CN107038148A (en) 2017-04-25 2017-04-25 The analytic method and resolver of XML document

Publications (1)

Publication Number Publication Date
CN107038148A true CN107038148A (en) 2017-08-11

Family

ID=59535857

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710279835.9A Pending CN107038148A (en) 2017-04-25 2017-04-25 The analytic method and resolver of XML document

Country Status (1)

Country Link
CN (1) CN107038148A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144500A (en) * 2018-07-30 2019-01-04 深圳点猫科技有限公司 A kind of skin file processing method and electronic equipment based on graphic programming
CN111831572A (en) * 2020-07-24 2020-10-27 北京思特奇信息技术股份有限公司 Batch comparison test method and device for realizing XML-JSON

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101699397A (en) * 2009-10-09 2010-04-28 上海宝信软件股份有限公司 Method for binding Java and XML data
CN103064859A (en) * 2011-10-21 2013-04-24 上海湾流仪器技术有限公司 Fast extensive makeup language (XML) analytic method based on variable memory pre-application and HASH
CN103123650A (en) * 2013-03-06 2013-05-29 同方知网(北京)技术有限公司 Extensible markup language (XML) data bank full-text indexing method based on integer mapping
CN103631597A (en) * 2013-12-09 2014-03-12 中博信息技术研究院有限公司 Extensible markup language (XML)-based WEB form engine device and method
CN104424334A (en) * 2013-09-11 2015-03-18 方正信息产业控股有限公司 Method and device for constructing nodes of XML (eXtensible Markup Language) documents

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101699397A (en) * 2009-10-09 2010-04-28 上海宝信软件股份有限公司 Method for binding Java and XML data
CN103064859A (en) * 2011-10-21 2013-04-24 上海湾流仪器技术有限公司 Fast extensive makeup language (XML) analytic method based on variable memory pre-application and HASH
CN103123650A (en) * 2013-03-06 2013-05-29 同方知网(北京)技术有限公司 Extensible markup language (XML) data bank full-text indexing method based on integer mapping
CN104424334A (en) * 2013-09-11 2015-03-18 方正信息产业控股有限公司 Method and device for constructing nodes of XML (eXtensible Markup Language) documents
CN103631597A (en) * 2013-12-09 2014-03-12 中博信息技术研究院有限公司 Extensible markup language (XML)-based WEB form engine device and method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘剑卓: "《Android手机游戏开发从入门到精通》", 31 May 2012, 中国铁道出版社 *
崔尚森等: "《Web应用开发技术.JSP(第二版)》", 31 March 2014, 西安电子大学出版社 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144500A (en) * 2018-07-30 2019-01-04 深圳点猫科技有限公司 A kind of skin file processing method and electronic equipment based on graphic programming
CN109144500B (en) * 2018-07-30 2021-01-05 深圳点猫科技有限公司 Skin file processing method based on graphical programming and electronic equipment
CN111831572A (en) * 2020-07-24 2020-10-27 北京思特奇信息技术股份有限公司 Batch comparison test method and device for realizing XML-JSON

Similar Documents

Publication Publication Date Title
Acampora et al. A hybrid evolutionary approach for solving the ontology alignment problem
JP6285943B2 (en) Ranking for recursive synthesis of string transformations.
US10747505B1 (en) API specification generation
US10122380B2 (en) Compression of javascript object notation data using structure information
JP4953468B2 (en) Method and apparatus for ontology data import / export
Gilson et al. From web data to visualization via ontology mapping
JP4975783B2 (en) Hierarchy construction method and hierarchy construction system
US20010037346A1 (en) Extensible markup language genetic algorithm
JP5370159B2 (en) Information extraction apparatus and information extraction system
CN107239492A (en) XML document is converted to the method and device that object, object are converted to XML document
CN112818092B (en) Knowledge graph query statement generation method, device, equipment and storage medium
CN107038148A (en) The analytic method and resolver of XML document
CN109933331A (en) Data transfer device and associated component between a kind of client-server
KR20150112442A (en) System and method for generating knowledge
KR101091592B1 (en) System and method for mobile-based ontology reasoning
CN114579605B (en) Table question-answer data processing method, electronic equipment and computer storage medium
US20230124296A1 (en) Method of natural language processing by performing semantic analysis using syntactic information, and an apparatus for the same
CN116346777A (en) Dictionary tree domain name matching method, device, equipment and storage medium
CN106708475A (en) Northbound data conversion method and apparatus
CN112733556B (en) Synchronous interactive translation method and device, storage medium and computer equipment
Saha et al. A unified dialogue management strategy for multi-intent dialogue conversations in multiple languages
Guo et al. Summarizing source code with Heterogeneous Syntax Graph and dual position
Yokoyama¹ et al. Semantic Variation Graphs: Ontologies for Pangenome Graphs
CN102339228B (en) Method for resolving context-free grammar
US11354290B2 (en) Query processing using inverted index of predicate statements

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170811

WD01 Invention patent application deemed withdrawn after publication