承接 tommykent1210/simple-dom 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tommykent1210/simple-dom

Composer 安装命令:

composer require tommykent1210/simple-dom

包简介

PHP wrapper for DOMElement.

README 文档

README

Build Status SensioLabsInsight Scrutinizer Code Quality PHP Version

A wrapper for PHP's DOMElement class that provides a nicer API for retrieving data from an element.

Installation

It can be installed in whichever way you prefer, but we recommend Composer.

{
    "require": {
        "wpillar/simple-dom": "dev-master"
    }
}

Usage

XML

$xml = \Pillar\SimpleDom\Element::xml('<?xml version="1.0"?>
    <Response>
        <Items>
            <Item>
                <ASIN>1477825274</ASIN>
                <ItemAttributes>
                    <Title>From the Cradle</Title>
                    <Actor>Brad Pitt</Actor>
                    <Actor>Angelina Jolie</Actor>
                </ItemAttributes>
            </Item>
        </Items>
    </Response>
');

foreach ($xml->getElements('Items') as $item) {
    $item->getValue('ASIN'); // 1477825274
    
    $item->getElement('ItemAtrributes'); // Pillar\SimpleDom\Element
    $item->getElement('ItemAttributes')->getValue('Title'); // 'From the Cradle'
    $item->getElement('ItemAttributes')->getValue('Actor'); // 'Brad Pitt'
    $item->getElement('ItemAttributes')->getValues('Actor'); // ['Brad Pitt', 'Angelina Jolie']
}

HTML

$html = \Pillar\SimpleDom\Element::html('<!DOCTYPE html>
    <html>
        <head>
            <title>My special website</title>
        </head>
        <body>
            <h1>Welcome to My Special Website!</h1>
            <p>Hello World!</p>
            <p>My name is Will</p>
        </body>
    </html>
');

$html->getElement('head')->getValue('title'); // 'My special website'
$html->getElement('body')->getValue('h1'); // 'Welcome to My Special Website'
$html->getElement('body')->getValue('p'); // 'Hello World!'
$html->getElement('body')->getValues('p'); // ['Hello World!', 'My name is Will']
$html->getElements('p'); // Pillar\SimpleDom\Element[]

Contributing

I prefer to use the GitHub Flow for working. So please submit a PR with your proposed changes stating the case for adding the changes with any documentation and tests that are appropriate.

This library aims to adhere to PSR-1, PSR-2 and PSR-4 standards so please make sure contributions adhere to those standards too. Also, if you spot any existing violations of those standards, PRs to fix them are most welcome.

License

The MIT License (MIT)

Copyright (c) 2014 Will Pillar

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.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-17