Use Chrome bookmarks to import IE or Maxthon programs (2)

Source: Internet
Author: User

In the previous article, we launched a program to test the program locally. I don't know if all the environments can run normally. This is a secondary problem, and the program itself is nothing difficult. After I finish, I will send the source code back to everyone and you can modify it based on your own needs. Here we will introduce the knowledge points encountered during the production process.

First, since we want to import chrome bookmarks into IE, we need to analyze the formats of chrome bookmarks and IE favorites files. What kind of conversion is required to ensure interoperability. You are familiar with IE favorites, which are at the file level. Different links and categories are represented by files and folders. The specific link file suffix is. url. After double-clicking it, You can directly navigate to the link page and open it in a text editor. The content in it misses the node and key value of the INI file. [Internetshortcut] and URL are commonly used. [Internetshortcut] indicates a webpage shortcut file. The URL after the URL equal sign is the URL of the link. Of course, there are other nodes and key names, serial numbers, icon addresses, and so on. These are not necessary.

The bookmarks file of chrome bookmarks is completely different. It is a single file, and the content in it is similar to XML. The classification in bookmarks is also displayed in this file, separated by different keywords. The following is a code example of chrome bookmarks:

   1:  {
   2:     "roots": {
   3:        "bookmark_bar": {
   4:           "children": [ {
   5:              "children": [ {
   6:                 "date_added": "12865393608170580",
   7:                 "name": "ClearType Tuner Step 1 Turn on Windows XP ClearType",
   8:                 "type": "url",
   9:                 "url": "http://www.microsoft.com/typography/cleartype/tuner/Step1.aspx "
  10:              } ],
  11:                 "date_added": "12865394044285991",
  12:                 "date_modified": "0",
  13:                 "name": "\u5730\u56FE\u7EBF\u8DEF",
  14:                 "type": "folder"
  15:              }

In this example, "Roots" indicates the root node of the bookmarks, "bookmark_bar" indicates the "bookmarks" column in chrome, and "children" indicates a set of bookmarks with subcolumns, in the collection symbol [], it is the bookmarks and subtopics under this topic, and the type: folder section after this is the information of this topic, such as the creation time, name. After analyzing the file structure, you will find:

Date_added indicates the time when the bookmarks were created.

Name indicates the name of a bookmark or column, in Unicode encoding format.

Type indicates whether the item is a bookmark or a column, URL indicates a bookmarkdonefile, and folder indicates a column.

In this way, we can find the corresponding relationship, replace the specific symbols and keywords in the file with the XML symbols and tags, and convert bookmarks to the XML format, which is most convenient for us to export bookmarks. Therefore, the following symbolic ing is defined here:

Roots -- <bookmark>

Bookmark_bar -- Cancel

Children -- bookmarkchild

Date_added -- <date_added>

Name -- <Name>

Type -- <type>

URL -- <URL>

The basic XML format after conversion is as follows:

   1:  <?xml version="1.0" encoding="GBK" ?>
   2:  <bookmark>
   3:        <bookmarkchild>
   4:        <bookmarkchild>
   5:        <date_added>12865393608170580</date_added>
   6:        <name>ClearType Tuner Step 1 Turn on Windows XP ClearType</name>
   7:        <type>url</type>
   8:        <url>http://www.microsoft.com/typography/cleartype/tuner/Step1.aspx</url>

Now, we will analyze the conversion of the file format here. In the next article, we will continue to perform the conversion and final export of bookmarks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.