Code Monkey home page Code Monkey logo

ji's Introduction

Ji: a Swift XML/HTML parser

Ji 戟

CI Status CocoaPods Version Carthage Compatible License Platform

Ji (戟) is a Swift wrapper on libxml2 for parsing XML/HTML.

Features

  • Build XML/HTML Tree and Navigate.
  • XPath Query Supported.
  • Comprehensive Unit Test Coverage.
  • Support Swift Package Manager (SPM). Linux compatible.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / watchOS 2.0+ / tvOS 9.0+
  • Xcode 8.0+

Installation

To integrate Ji into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'Ji', '~> 5.0.0'

Then, run the following command:

$ pod install

To integrate Ji into your Xcode project using Carthage, specify it in your Cartfile:

github "honghaoz/Ji" ~> 5.0.0

Prerequisites

  • OSX
brew install libxml2
brew link --force libxml2
  • Linux
$ sudo apt-get install libxml2-dev

Update Package.swift

To integrate Ji in your project, add the proper description to your Package.swift file:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/honghaoz/Ji.git", from: "5.0.0")
    ],
    targets: [
        .target(
            name: "YOUR_TARGET_NAME",
            dependencies: ["Ji"]
        ),
        ...
    ]
)

Manually

If you prefer not to use a dependency manager, you can integrate Ji into your project manually.

  • Add sources into your project:

    • Drag Ji.swift, JiHelper.swift and JiNode.swift in Sources/Ji folder into your project.
    • Drag Sources/Clibxml2 folder into your project.
  • Configure your project:

    • Open project, select the target, under Build Settings, in Header Search Paths, add $(SDKROOT)/usr/include/libxml2
    • Under Build Settings, in Import Paths, add $(SRCROOT)/Clibxml2 (Make sure this is the path to the Clibxml2 folder)

Usage

If you are using CocoaPods to integrate Ji. Import Ji first:

import Ji
  • Init with URL:
let jiDoc = Ji(htmlURL: URL(string: "http://www.apple.com/support")!)
let titleNode = jiDoc?.xPath("//head/title")?.first
print("title: \(String(describing: titleNode?.content))") // title: Optional("Official Apple Support")
  • Init with String:
let xmlString = "<?xml version='1.0' encoding='UTF-8'?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>"
let jiDoc = Ji(xmlString: xmlString)
let bodyNode = jiDoc?.rootNode?.firstChildWithName("body")
print("body: \(String(describing: bodyNode?.content))") // body: Optional("Don\'t forget me this weekend!")
  • Init with Data:
let googleIndexData = try? Data(contentsOf: URL(string: "http://www.google.com")!)
if let googleIndexData = googleIndexData {
    let jiDoc = Ji(htmlData: googleIndexData)!
    let htmlNode = jiDoc.rootNode!
    print("html tagName: \(String(describing: htmlNode.tagName))") // html tagName: Optional("html")

    let aNodes = jiDoc.xPath("//body//a")
    if let firstANode = aNodes?.first {
        print("first a node tagName: \(String(describing: firstANode.name))") // first a node tagName: Optional("a")
        let href = firstANode["href"]
        print("first a node href: \(String(describing: href))") // first a node href: Optional("http://www.google.ca/imghp?hl=en&tab=wi")
    }
} else {
    print("google.com is inaccessible")
}

let 戟文档 = (htmlURL: URL(string: "https://cocoapods.org/pods/Ji")!)
let attribution = 戟文档?.xPath("//ul[@class='attribution']")?.first
print("作者(Author): \(String(describing: attribution?.content))") // 作者(Author): Optional("ByHonghao Zhang")

License

The MIT License (MIT)

Copyright (c) 2019 Honghao Zhang (张宏昊)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ji's People

Contributors

everald avatar honghaoz avatar nikstar avatar ujell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ji's Issues

Carthage support?

Hi, I really love this project! Thank you so very much for building it.

Is there a chance though that you could support installing via Carthage as well? Cocoapods is great, no question, but Carthage is pretty cool as well and a staggering amount of great projects already support both giving the users an option of how to integrate with their project.

Thanks for considering 😊

child node xPath's results equal to document

Child node xPath's results equal to document's.Is it design to act like this?Or is a bug?

Chinese: 子node 的xpath的结果跟document一样,是这么设计的还是bug啊?哥们。我想在子node继续xpath啊

xPath fails if there's xmlns

Evaluating XPath strings fails if one of the elements is defined with XML namespace.
Most of the frameworks offer a method to register namespaces but I found no way for Ji.
So I guess many of the common XML/HTML files can't be queried by your xPath function.

nw_endpoint_handler_add_write_request

I used too much?

nw_endpoint_handler_add_write_request [1.1 210.56.48.75:80 failed socket-flow (satisfied)] cannot accept write requests
2017-09-12 10:17:45.788013+0800 Anthill[37033:1641436] [] tcp_connection_write_eof_block_invoke Write close callback received error: [22] Invalid argument

有些特定xpath不能解析

    let contentData = NSData(contentsOfURL: NSURL(string: "http://v2ex.com/t/223195")!)
    let jiDoc = Ji(htmlData: contentData!)
    let nodes = jiDoc?.xPath("//div[starts-with(@id, 'r_')]")

是想解析里面含r_ 的div,用chrome 的xpath helper 可以将里面帖子全部解析出来,但是如果用Ji来解析 话,nodes没有结果。

看了下hpple也有这个问题,是什么原因?

XPath error : Invalid expression

我之前用的是Kanna,运行都正常,但是有少许内存泄漏。
换Ji库后,macOS下运行很完美,但是相同代码到Linux上所有XPath都会报错。
XPath error : Invalid expression

Re-writing HTML

Hi,

I'd like to use Ji to update tag attributes and re-write the amended HTML. Running a quick test, the updated attributes weren't shown in the updated description. Am I missing something?

Thanks for your work
Ash

cEncoding null pointer

Hey again :)

I've been running into some issues trying to correctly decode the content of a specific page. The response header says it's utf-8, the page itself says is latin-1. Decoding with utf-8 works when done by hand, but I kept having encoding issues when creating an HTML document with Ji.

let htmlDoc = Ji(htmlData: data, encoding: NSUTF8StringEncoding)

I tried a bunch of different NSStringEncodings, most with the same results, which seemed weird. Having a look at Ji's code I found cEncoding to be a null pointer every time so htmlReadMemory() probably defaults to something besides utf-8.

let cEncoding: UnsafePointer<CChar> = CFStringGetCStringPtr(cfEncodingAsString, 0)
if cEncoding == nil {
    print("cEncoding is a null pointer")
}

If I hardcode the encoding of the page as a string literal a few lines lower everything seems to be working.

htmlDoc = htmlReadMemory(cBuffer, cSize, nil, "utf-8", options)

I hope this helps debugging this issue, I don't have much of a clue^^

有没有方法只解析本级别的content,不解析下级的content

Hi, 晚上好,
在解析时,预想只解析本级别的content,有没有方便的实现办法,
html字符串如下:
jiissue
代码如下:
let elements = JiDocument.xPath("//a")?.first?.content
调试输出如下:
3742c6f3-4280-4eeb-87c3-36a349d8d4b8

问题:本次解析时,我只想得到 "新闻" 这个content,不希望下级的2267也解析出来。

新手,请多指教,
感谢!🙏

Merge swift-2.0 with master

Hey can you merge swift-2.0 branch with master now that iOS 9 and swift 2 dropped. Carthage currently complains that the 2.0 branch doesn't have a framework scheme. For now I can just build it manually as a workaround. Thanks!

Invalid XPath

Hello, when using an XPath like this:

guard let jiHTML = Ji(htmlString: html) else {
     dispatchGroup.leave()
     return
}
guard let scoreboxNodes = jiHTML.xPath("//div[@class='new-score-box-wrapper']") else {
      dispatchGroup.leave()
      return
}

I get an invalid predicate error. The path that i have given is valid. I also tried switching to the swift4 branch but that didn't work either.

tag 1.3.0 Carthage compile error

I tried to compile tag 1.3.0 under macOS 10.12 (16A323) with Carthage 0.18, Xcode 8(8A218a), but get compilation errors.
I am currently using commit "e14bb36" for swift 2.3 development which compiled fine.
Just wondering any plan to tag another compilable version or a fix for swift 2.3 compatible release?

........................................
prompt $ carthage build Ji --platform iOS --toolchain com.apple.dt.toolchain.Swift_2_3
*** xcodebuild output can be found in /var/folders/hq/kkxg8y3j77v6y6s4lkvhbhm80000gn/T/carthage-xcodebuild.9qOWGh.log
*** Building scheme "Ji iOS" in Ji.xcworkspace
** BUILD FAILED **

The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
CompileSwift normal armv7
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/DerivedSources/Ji_iOS_Tests-Swift.h /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests-Swift.h
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/DerivedSources/Ji_iOS_Tests-Swift.h /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests-Swift.h
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm.swiftmodule /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests.swiftmodule
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm.swiftdoc /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests.swiftdoc
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm64.swiftmodule /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests.swiftmodule
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm64.swiftdoc /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests.swiftdoc
Ld /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji\ iOS\ Tests normal armv7
Ld /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji\ iOS\ Tests normal arm64
CreateUniversalBinary /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest/Ji\ iOS\ Tests normal armv7\ arm64
GenerateDSYMFile /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest.dSYM /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest/Ji\ iOS\ Tests
(14 failures)
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiNodeXMLTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/htmlXPathTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiNodeHTMLTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/xmlXPathTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiNodeXMLTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/htmlXPathTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/JiNodeHTMLTests.swift:11:18: error: module 'Ji' was not compiled for testing
/Users/username/Documents/project/Carthage/Checkouts/Ji/Tests/xmlXPathTests.swift:11:18: error: module 'Ji' was not compiled for testing
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji iOS Tests.build/Objects-normal/armv7/Ji iOS Tests (No such file or directory)
error: cannot parse the debug map for "/Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji iOS Tests.xctest/Ji iOS Tests": No such file or directory
A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/username/Documents/project/Carthage/Checkouts/Ji/Ji.xcworkspace -scheme "Ji iOS" -configuration Release -sdk iphoneos -toolchain com.apple.dt.toolchain.Swift_2_3 ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** BUILD FAILED **

The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
CompileSwift normal armv7
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/DerivedSources/Ji_iOS_Tests-Swift.h /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests-Swift.h
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/DerivedSources/Ji_iOS_Tests-Swift.h /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests-Swift.h
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm.swiftmodule /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests.swiftmodule
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm.swiftdoc /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji_iOS_Tests.swiftdoc
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm64.swiftmodule /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests.swiftmodule
Ditto /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji_iOS_Tests.swiftmodule/arm64.swiftdoc /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji_iOS_Tests.swiftdoc
Ld /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/armv7/Ji\ iOS\ Tests normal armv7
Ld /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Intermediates/Ji.build/Release-iphoneos/Ji\ iOS\ Tests.build/Objects-normal/arm64/Ji\ iOS\ Tests normal arm64
CreateUniversalBinary /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest/Ji\ iOS\ Tests normal armv7\ arm64
GenerateDSYMFile /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest.dSYM /Users/username/Library/Developer/Xcode/DerivedData/Ji-hldoeromjgwrlwckainrykenhdur/Build/Products/Release-iphoneos/Ji\ iOS\ Tests.xctest/Ji\ iOS\ Tests
(14 failures)

Swift 3 Compile Error

I'm using Ji 2.0.0 through the ReadabilityKit, but I get a Swift Compile Error with 155 errors in Xcode 8.

add prefix

Hi!你好

当我在解析这个的时候 entry [https://github.com/showcases.atom] 总是没有值。

好像是因为 prefix 的原因。请问有什么解决办法吗

谢谢 : ]

有關解析 HTML

你好,我在使用 Ji 時,遇到了點問題..
我的 HTML CODE 如下:

<!doctype html>
<html lang="en" prefix="op: http://media.facebook.com/op#">
  <head>
    <meta charset="utf-8">
    <link rel="canonical" href="http://life.tw/?app=view&no=431445">
    <link rel="stylesheet" title="Lifetw" href="#">
    <meta property="fb:article_style" content="Lifetw">
    <title>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</title>
  </head>
  <body>
  <article>
          <header>
    <figure>
    <img src="http://images.900.tw/upload_file/33/content/dc38a115-5732-b707-34d2-83513508a273.jpg">
    <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
    </figure>

    <h2> 可愛的兔兔應該是繼汪星人和喵星人之外比較常見的家庭寵物,而在日本就有一隻垂耳兔PuiPui不只本身擁有超萌的高顏值,她的主人也很用心地幫PuiPui準備專屬服裝,並且在Instagram上分享牠的變裝... </h2>


    <address>
      Styletc樂時尚    </address>

    <time class="op-published" dateTime="2016-05-11T09:15:25+08:00">Wed, 11 May 2016 09:15:25 +0800</time>
    <time class="op-modified" dateTime="2016-05-11T09:15:25+08:00">Wed, 11 May 2016 09:15:25 +0800</time>
    </header>    
    <p>可愛的兔兔應該是繼汪星人和喵星人之外比較常見的家庭寵物,而在日本就有一隻垂耳兔PuiPui不只本身擁有超萌的高顏值,她的主人也很用心地幫PuiPui準備專屬服裝,並且在Instagram上分享牠的變裝日記,讓PuiPui成為超多粉絲追蹤的人氣時尚潮兔,快一起來認識PuiPui吧!</p>

<figure>
  <img src="http://images.900.tw/upload_file/33/content/dc38a115-5732-b707-34d2-83513508a273.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼穿上可愛的學生制服、萌兔PuiPui要在櫻花的目送下上學去啦!</p>
<a href="http://www.styletc.com/wp-content/uploads/2016/05/110.jpg">
<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/110.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>
</a>

<p>▼到了秋天就換上福爾摩斯裝來襯托深沉的秋意!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/28.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼萬聖節這個最重要的變裝日子當然要穿上可愛的巫師裝!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/36.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼PuiPui的毛絨絨可愛模樣為什麼會這麼適合英國軍人裝啊~</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/46.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼地表最萌的聖誕小精靈,可以請聖誕老公公送一隻這樣的小精靈給我嗎?</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/53.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼雖然是會融化人心的可愛外表,但穿上了正式的日式傳統衣服也意外地有堂堂男子漢的氣息啊</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/61.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼我不只是主人捧在手掌心疼的小兔兔,也是我們家的國王喔(威顏貌)</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/71.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼穿上帥帥的水手服到公園進行偷親女朋友計畫成功!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/81.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼夏天到冰店打工就是要一身清爽的夏日浴衣才可以~</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/9.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼主人:「要乖乖的戴好帽子帥帥的出門喔!」</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/101.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼為了搭配世界盃主題來場足球員cosplay好了,但也不要小看兔兔的靈敏度啊!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/111.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼穿上全套英國紳士西裝之後根本就是個一秒奪取女心的寮妹高手!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/121.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼今天的扮裝重點是&hellip;&hellip;加班中的上班族?!</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/131.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼來檢查一下主人拍我的照片成果如何?</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/141.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>▼嗯&hellip;&hellip;今天到底該穿哪一件呢(苦惱中)</p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/151.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>還想看更多萌兔PuiPui的穿搭日記嗎?那就快來追蹤「mumitan」這個Instagram帳號&gt;&gt;&gt;<a href="https://www.instagram.com/mumitan/">https://www.instagram.com/mumitan/</a></p>

<figure>
  <img src="http://www.styletc.com/wp-content/uploads/2016/05/161.jpg" />
  <figcaption>哥什麼造型都能消化!超卡哇伊又高顏值的萌兔PuiPui穿搭日記圖集...第12張簡直是撩妹高手呀!</figcaption>
</figure>


<p>看更多&gt;&gt;&gt;</p>
<p><a href="http://www.styletc.com/archives/129688">毛小孩也要開萬聖趴,寵物變裝造型靈感大集合!</a></p>
<p><a href="http://www.styletc.com/archives/229939">背面萌度x2,快來追蹤柯基屁屁Instagram帳號!</a></p>
<p><a href="http://www.styletc.com/archives/220203">《管教惡貓》主持人傑克森蓋勒克西獨家馭貓術大公開</a></p>

<p>圖片來源:<a href="https://www.instagram.com/mumitan/">mumitan&nbsp;Instagram</a></p>

<p>【<a href="http://www.styletc.com/archives/233782" target="_blank">本文出處</a>,更多精采內容請上《<a class="navbar-link" href="http://www.styletc.com/">Styletc樂時尚</a>》官方網站;《<a class="navbar-link" href="https://www.facebook.com/pages/Styletc%E6%A8%82%E6%99%82%E5%B0%9A/1436316026651285?fref=ts">Styletc樂時尚</a>》官方粉絲團。未經授權,請勿轉載!】</p>
<figure class="op-ad">
<iframe src="http://fbarticle.life.tw/dfp.html" height="280" width="336"></iframe>
</figure>
        <footer>
    <aside>
      Life Talk copyright© 2011 ALL ACCESS HOLDING GROUP LTD., All rights reserved. 客服專線:0800-090-789
    </aside>
    <small>© Life生活網</small>
  </footer>  </article>
  </body>
</html>

我想去Parse 每一個 'p', 'figure.img', 'figure.figcaption' .. 等
試了好多方式,好像都只能單獨取一個 tag 而已..@@?

不知是否我的寫法有誤:

  let elements = jiDoc!.xPath("//p")!

            let count = elements.count
            for i in 0..<count {
                let x = elements[i].rawContent
                debugPrint("x : \(x)")
            }

Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “(null)” were found. CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS 8.4'

Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “(null)” were found.
CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS 8.4'

Any ideas?

SPM 模拟器中运行很好,真机构建报错

ld: warning: ignoring file /usr/local/Cellar/libxml2/2.9.10_1/lib/libxml2.dylib, building for iOS-arm64 but attempting to link with file built for macOS-x86_64

Undefined symbols for architecture arm64:

Undefined symbol: _xmlXPathCmpNodes
Undefined symbol: _xmlXPathEvalExpression

gbk error "encoding error : input conversion failed due to input error"(swift3)

let data = try? Data(contentsOf: URL(string: "http://m.263xs.com/info-83441/")!)		
let gbk = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue))
let string = String(data: data!, encoding: String.Encoding(rawValue: gbk)) // **it's OK!**
let doc = Ji(data: data, encoding: String.Encoding(rawValue: gbk), isXML: false) // **it show error: "encoding error : input conversion failed due to input error"**

Swift 4, iOS 11, and Xcode 9

I'm persistently getting the error:

XPath error : Invalid predicate
XPath error : Invalid expression

During build time for a project on iOS 11, Xcode 9, and Swift 4

Include of non-modular header-error

I get an Include of non-modular header inside framework module 'Ji.*' when downloading Ji via Cocoapods.

All headers are public though, which should fix that... but it doesn't.

These happen on all Ji-includes in these headers.

发现一个bug

发现一个bug:

<div>
  <a href="a1">
    <img src="img1">
  </a>

  <a href="a2">
    <img src="img2">
  </a>

  <a href="a3">
    <img src="img3">
  </a>
</div>

通过xPath拿到一个Node列表,然后遍历这个列表,调用每个Node的xPath方法:

let nodes = Ji.xPath("//div/a")

for node in nodes {
    let test1 = node.xPath("img")
    let test2 = node.xPath("//img")
}

照道理说test2的内容 应该等于test1的,因为现在xPath搜索的环境是node的html中,都只有一个,但是test2把全文的img都检索出来了。

Unable to use Ji on macOS 10.13.4

macOS 10.13.4
Xcode 9.3

My application uses "honghaoz/Ji" version "2.1.0".

When I compile my application, I get the following error:

Module compiled with Swift 4.0.3 cannot be imported in Swift 4.1: /Users/[...]/Projects/[...]/Carthage/Build/Mac/Ji.framework/Modules/Ji.swiftmodule/x86_64.swiftmodule

Is there a newer version of "honghaoz/Ji" available that supports Swift 4.1?

Thanks

Carthage build issue

Since Swift isn't ABI stable yet, the prebuilt binaries that Carthage gets from Github on the releases page are not working with the latest versions of XCode/Swift. Would recommend that they be removed, as XCode won't build with them.

GBK编码的HTML字符串初始化Ji后里面的内容全乱码了

网页是GBK编码的,然后我这样初始化Ji

 let NSGBKStringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue))
 var htmlString = String(data: data!, encoding: NSGBKStringEncoding)
 let ji = Ji(htmlString: htmlString!, encoding: NSGBKStringEncoding)

我这样转换后ji里的内容中文的全乱码了,不知道为什么

网站是梦幻西游论坛:http://my.netease.com/forum.php

Undefined symbols

Hi there,

I'm newbie in Swift and for now I am facing this kind of issue. I tried various solutions which I found on StackOverflow, but errors did not disappeared. I have no idea what's going on, maybe something with imported settings. Please, can you give me some advice?

Thanks!

Snímka obrazovky 2019-12-20 o 22 09 31

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.