CN104376008A - Method for replacing XML (extensive markup language) absolute path - Google Patents

Method for replacing XML (extensive markup language) absolute path Download PDF

Info

Publication number
CN104376008A
CN104376008A CN201310353703.8A CN201310353703A CN104376008A CN 104376008 A CN104376008 A CN 104376008A CN 201310353703 A CN201310353703 A CN 201310353703A CN 104376008 A CN104376008 A CN 104376008A
Authority
CN
China
Prior art keywords
absolute path
xml
file
path
absolute
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
CN201310353703.8A
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.)
SHENZHEN ZHONGHONG TECHNOLOGY Co Ltd
Original Assignee
SHENZHEN ZHONGHONG 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 SHENZHEN ZHONGHONG TECHNOLOGY Co Ltd filed Critical SHENZHEN ZHONGHONG TECHNOLOGY Co Ltd
Priority to CN201310353703.8A priority Critical patent/CN104376008A/en
Publication of CN104376008A publication Critical patent/CN104376008A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion
    • G06F16/86Mapping to a database

Abstract

The invention relates to a method for replacing an XML (extensive markup language) absolute path. The method comprises the following steps of (S100) reading an XML file; (S200) retrieving the start tag and the end tag of an element in the XML file; (S300) extracting a first absolute path between the start tag and the end tag of the element; (S400) inserting a second absolute path between the start tag and the end tag of the element; and (S500) saving the XML file. The method for replacing the XML absolute path is capable of quickly replacing the absolute path in the XML file and ensuring that the XML file can be correctly displayed and operated on different platforms. By recording each replacement, absolute paths of a plurality of XML files can be replaced in bulk. The workload is greatly reduced, and the working efficiency is improved.

Description

XML absolute path conversion method
Technical field
The present invention relates to XML technology, more particularly, relate to a kind of XML absolute path conversion method.
Background technology
Extend markup language (Extensible Markup Language, XML), a kind ofly make it have structural markup language for electroactive marker son file, can be used for flag data, definition data type, be the source language that the markup language of a kind of user of permission to oneself defines.XML file can be applied in the field such as interface, multi-format document structure tree of program.The multimedia elements such as such as picture can be inserted by the mode in path in XML file; but in the process of exploitation, usually occur that the transfer of file carrys out collaborative work; the absolute path that at this time multimedia element uses there will be often cannot the problem of regular orientation, causes the page normally to show.
Summary of the invention
The object of the invention is to, for existing XML file when use absolute path, the problem that cannot normally use can be occurred on different platforms, provide a kind of XML absolute path conversion method to overcome above-mentioned defect.
Solution of the above problems of the present invention is, provides a kind of XML absolute path conversion method, comprises the following steps:
S100, reading XML file;
Element tags starting character in S200, retrieval XML file and element tags end mark;
S300, extract the first absolute path between element tags starting character and element tags end mark;
S400, the second absolute path is inserted between element tags starting character and element tags end mark;
S500, preservation XML file.
XML absolute path conversion method of the present invention, wherein step S300 also comprises:
Absolute path address identical with the first absolute path in S301, extraction XML file.
XML absolute path conversion method of the present invention, wherein step S400 also comprises:
Second absolute path is put between element tags starting character and element tags end mark.
XML absolute path conversion method of the present invention, also comprises S600:
Generate log file, log file record first absolute path and the second absolute path.
XML absolute path conversion method of the present invention, the first absolute path comprises the first path indexing and the first file index that are arranged in order; Second absolute path comprises the second path indexing and the second file index that are arranged in order; First file index is identical with the second file index; In step S300, extract the first path indexing of the first absolute path, in step S400, the second path indexing is put between element tags starting character and element tags end mark.
XML absolute path conversion method of the present invention, also comprises reading log file, according to the first absolute path and second absolute path of the record in log file, carries out absolute path conversion to other XML file.
Implement XML absolute path conversion method of the present invention can replace the absolute path in XML fast, make XML file normally can show work on different platforms.By record replacement each time, make the replacement operation that can carry out batch to multiple XML file, substantially reduce workload, improve work efficiency.
Accompanying drawing explanation
Below in conjunction with accompanying drawing, the present invention will be described, wherein:
Fig. 1 is the schematic diagram quoting picture in XML file of the present invention;
Fig. 2 is the method flow diagram of XML absolute path conversion method of the present invention;
Fig. 3 is the log file schematic diagram generated in XML absolute path conversion method of the present invention.
Embodiment
Be illustrated in figure 1 the schematic diagram of the XML file related in the present invention, for picture, when needs insert a picture in XML file 100 time, between picture tag starting character 110 and picture tag end mark 130, insert an absolute path 120.Picture tag starting character 110 is " pic " and the angle brackets " < " of representative picture key element and the combination of " > ", picture tag end mark 130 then correspondence " pic " front add back slash " ".Absolute path between picture tag starting character 110 and picture tag end mark 130 120 is the full address of image file on current platform needing to insert.These are only the situation of insert pictures, in time needing to insert different elements, then need to change picture tag starting character 110 and picture tag end mark 130 correspondence into suitable element tags starting character and element tags end mark.On the one hand due to different for the mode of file management in different platforms, such as, absolute path 120 in Fig. 1 is " C: windows 1.jpg " is the expression under windows platform, but the expression in Linux is probably "/mnt/sda1/1.jpg ", and different developers is general also different for the preservation position of file on same platform, like this when XML file 100 forwards other platforms to time, be easy to just to there will be absolute path 120 cannot match on the file of original definition, cause cannot normally using of XML file.
The method that for this reason present invention employs as Fig. 2 is changed absolute path.First in the step s 100, developer first uses editing machine to open needs to carry out the XML file that operates, such as, XML file 100 in Fig. 1.Then find out element tags starting character and element tags end mark in step s 200, such as, <pic> and < in Fig. 1 pic>, then in step S300, absolute path is extracted, due in XML file, nested label can be used, therefore in this step first by <pic> and < other labels symbol between pic> reject, with remaining path address, then determine that this path address is absolute path or relative path: all relative paths all start with period ". ", relative path is not processed, only absolute path is extracted between element tags starting character and element tags end mark, be then the first absolute path for this path address separated, then in step S400, we are by new path address, i.e. the second absolute path, are inserted on the position of original first absolute path, complete replacement operation, after this operation similar to previous step is carried out for whole XML file, whole XML file is made all to complete replacement operation, namely in step S300, further carry out step S301, whole XML file is searched and first absolutely spends the identical path address in path with preceding step and carry out, for the file that whole operating process all completes, preserve in step S500, and in step S600, record is carried out in all replacements related to, generate log file.Like this for follow-up XML file, directly can carry out path replacement according to this log file, save time.
Consider that general filename has identical expression on different platforms, namely file index is identical, the different path indexings being only previous section in absolute path.Therefore when carrying out step S300 and step S400, can only to extract, replacement path index part, to reduce the workload of replacement.
As shown in Figure 3, be the log file generated in step S600, the absolute path that the picture that have recorded a wherein place in XML file in this log file is quoted replaces history.Time first developer receives XML file, the first absolute path of the picture quoted is " C: media 1.jpg "; But on the platform used the first developer, this image file leaves in the second absolute path "/mnt/sda2/media/1.jpg ", therefore, after have employed switch process of the present invention, quoting in this XML file is quoted for same image file, is converted to "/mnt/sda2/media/1.jpg ", normally shows on the platform of the first developer to facilitate this XML file.After this, this XML file turns and proceeds editor by the second developer, and adopts same switch process.Now, the second absolute path originally in the first developer then becomes the first absolute path in the platform of the second developer.If just occur, two absolute path are identical, without the need to situation about changing, carried out record too, as the N developer in Fig. 3, with facilitate this developer upper once replace time find this path fast.
Log file shown in Fig. 3, only for the replacement history that 1 image in 1 XML file is quoted, usually needs to replace the multiple elements in multiple XML file in the exploitation of reality.Now, we can be expanded to database according to the log file of Fig. 3.To support that the multiposition of multifile is changed.When developer's catcher is researched and developed, first run this database, and each XML file is changed, and then research and develop, and after research and development terminate, the information in the exhausted degree path more in new database.
These are only the specific embodiment of the invention, scope of the present invention can not be limited with this, the equalization change that those skilled in the art in the art do according to this creation, and the change that those skilled in that art know, all still should belong to the scope that the present invention is contained.

Claims (6)

1. an XML absolute path conversion method, is characterized in that, comprises the following steps:
S100, reading XML file;
Element tags starting character in S200, retrieval XML file and element tags end mark;
S300, extract the first absolute path between element tags starting character and element tags end mark;
S400, the second absolute path is inserted between element tags starting character and element tags end mark;
S500, preservation XML file.
2. XML absolute path conversion method according to claim 1, it is characterized in that, described step S300 also comprises:
Absolute path address identical with the first absolute path in S301, extraction XML file.
3. XML absolute path conversion method according to claim 2, it is characterized in that, described step S400 also comprises:
Second absolute path is put between element tags starting character and element tags end mark.
4. XML absolute path conversion method according to claim 1, is characterized in that, also comprise S600:
Generate log file, log file record first absolute path and the second absolute path.
5. XML absolute path conversion method according to claim 4, is characterized in that, the first absolute path comprises the first path indexing and the first file index that are arranged in order; Second absolute path comprises the second path indexing and the second file index that are arranged in order; First file index is identical with the second file index; In step S300, extract the first path indexing of the first absolute path, in step S400, the second path indexing is put between element tags starting character and element tags end mark.
6. XML absolute path conversion method according to claim 4, is characterized in that, also comprise reading log file, according to the first absolute path and second absolute path of the record in log file, carries out absolute path conversion to other XML file.
CN201310353703.8A 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path Pending CN104376008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310353703.8A CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310353703.8A CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Publications (1)

Publication Number Publication Date
CN104376008A true CN104376008A (en) 2015-02-25

Family

ID=52554928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310353703.8A Pending CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Country Status (1)

Country Link
CN (1) CN104376008A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110427343A (en) * 2019-06-27 2019-11-08 苏州浪潮智能科技有限公司 A kind of method of deployment file, computer equipment and readable storage medium storing program for executing
CN112733056A (en) * 2021-04-02 2021-04-30 北京百家视联科技有限公司 Document processing method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170070A1 (en) * 2001-03-01 2002-11-14 Rising Hawley K. Multiple updates to content descriptions using a single command
CN1584884A (en) * 2003-08-20 2005-02-23 富士通株式会社 Apparatus and method for searching data of structured document
CN101986311A (en) * 2010-11-17 2011-03-16 浙江省电力试验研究院 Method for buffering node elements when rapidly processing large-scale XML file

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170070A1 (en) * 2001-03-01 2002-11-14 Rising Hawley K. Multiple updates to content descriptions using a single command
CN1584884A (en) * 2003-08-20 2005-02-23 富士通株式会社 Apparatus and method for searching data of structured document
CN101986311A (en) * 2010-11-17 2011-03-16 浙江省电力试验研究院 Method for buffering node elements when rapidly processing large-scale XML file

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110427343A (en) * 2019-06-27 2019-11-08 苏州浪潮智能科技有限公司 A kind of method of deployment file, computer equipment and readable storage medium storing program for executing
CN112733056A (en) * 2021-04-02 2021-04-30 北京百家视联科技有限公司 Document processing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109948134B (en) Report automatic generation method, system, electronic equipment and storage medium
CN100462929C (en) Method and medium and method for recovering data using a timeline-based computing environment
Sanderson et al. Automatic data organization, storage, and analysis of camera trap pictures
JP4796185B2 (en) Business flow diagram generation program, business flow diagram generation device, and business flow diagram generation method
CN102103500B (en) Operation monitoring device
US20120210298A1 (en) Locating changes in source code
US10789418B2 (en) Batch generation of links to documents based on document name and page content matching
CN101667118A (en) Method and device for multi-language version development and replacement
CN101639755A (en) Method for supporting picture input and equipment thereof
CN103917960A (en) Storage apparatus and duplicate data detection method
CN102693233B (en) A kind of method and device realizing c bookmart
JP2012064297A (en) Content file classification device and content file classification method
Sparks MAC at Work
CN101551793A (en) Method for saving and editing files
CN102624770B (en) Information extraction method and extraction information network storage management system based on cloud calculation
CN104376008A (en) Method for replacing XML (extensive markup language) absolute path
CN104090924B (en) The method for cleaning and device of a kind of private data
US11687732B2 (en) Content management systems for providing automated translation of content items
JP2006107375A (en) System and method for document management, program, and storage medium
CN103714179A (en) Multi-language supporting method and system for system blog
US8615522B2 (en) Computing device, storage medium and method for outputting dimension data using the computing device
CN103942186A (en) Method and system for managing documents
CN113434748A (en) Template annotation based distributed crawler method and device, computer device and computer readable storage medium
CN102254155A (en) Accurate font activation
JP2009265902A (en) Document management device, document management method, information processing program, and recording medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20150225

RJ01 Rejection of invention patent application after publication