<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          FuziXML/HTML 解析器

          聯(lián)合創(chuàng)作 · 2023-09-21 23:25

          Swift 實現(xiàn)的輕量快速的 XML/HTML 解析器。

          Mattt Thompson大神的 Ono (斧) 是iOS/OSX平臺上非常好用的一個XML/HTML 解析庫。用ObjectiveC實現(xiàn)的Ono在Swift的應用里雖然可以使用,卻有諸多不便。因此鄙人參照了Ono對libxml2的封裝方式,對類和方法進行了重新設(shè)計弄出了這個小庫。同時修正了Ono存在的一些邏輯上和內(nèi)存管理方面的bug。

          中文README

          https://github.com/cezheng/Fuzi/blob/master/README-zh.md

          示例代碼:

          let xml = "..."
          do {
            let document = try XMLDocument(string: xml)
          
            if let root = document.root {
              // Accessing all child nodes of root element
              for element in root.children {
                print("\(element.tag): \(element.attributes)")
              }
          
              // Getting child element by tag & accessing attributes
              if let length = root.firstChild(tag:"Length", inNamespace: "dc") {
                print(length["unit"])     // `unit` attribute
                print(length.attributes)  // all attributes
              }
            }
          
            // XPath & CSS queries
            for element in document.xpath("") {
              print("\(element.tag): \(element.attributes)")
            }
          
            if let firstLink = document.firstChild(css: "a, link") {
              print(firstLink["href"])
            }
          } catch let error {
            print(error)
          }
          瀏覽 18
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  呦小泬泬精品泬泬在线看 | 在线视频中文字幕一区 | 99久久精品免费看国产四区 | 五月天色婷婷中文影院 | 变态另类av |