SIParser 1.2

SIParser 1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年8月

Silence0201 维护。



  • Silence

HTMLParser


SIParser:一个简单的 Html/XML 解析器

使用说明

导入

手工导入

  1. 将项目下的 HTMLParser 导入项目中,
  2. 点击 Bulid Phases -> Link FrameWork and Libraries,添加 libxml2.tbdlibxml2.dylib
  3. 在项目设置中 Bulid Setting -> header search paths,添加 $(SDKROOT)/usr/include/libxml2

Pod 安装

pod 'SIParser', '~> 0.1.0'

使用

  1. 导入头文件

    #import "Parser.h"
  2. 初始化Parser

    NSString *htmlString = @"<username>我是username自定义样式</username><password size='20'>我是password自定义样式,注意属性内容</password>";
    SIHTMLParser *htmlParser = [[SIHTMLParser alloc] init];
  3. 查询节点信息

    SINodeList *nodes = [htmlParser nodeListWithString:htmlString];
  4. 转换为富文本

    //自定义样式
    NSDictionary *customStyles = @{
                                   NSForegroundColorAttributeName: [UIColor orangeColor],
                                   NSBackgroundColorAttributeName: [UIColor blueColor]
                                   };
    [htmlParser addStyle:customStyles forTag:@"username"];
    NSAttributedString *attributedString = [htmlParser parseString:htmlString];
  5. 更多使用请查看头文件说明

HTMLParser

SIParser 采用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。