php - DOMElement获取带html标签的内容
PHP中文网
PHP中文网 2017-04-10 14:51:03
0
1
388

如题

DOMElement Object
(
    [tagName] => p
    [schemaTypeInfo] => 
    [nodeName] => p
    [nodeValue] => 
    Article Name
    Contents of article
    One
      Two
      Three
      Four
      Five

    [nodeType] => 1
    [parentNode] => (object value omitted)
    [childNodes] => (object value omitted)
    [firstChild] => (object value omitted)
    [lastChild] => (object value omitted)
    [previousSibling] => 
    [attributes] => (object value omitted)
    [ownerDocument] => (object value omitted)
    [namespaceURI] => 
    [prefix] => 
    [localName] => p
    [baseURI] => 
    [textContent] => 
    Article Name
    Contents of article
    One
      Two
      Three
      Four
      Five

)

用textContent获取的都是不带标签的内容...不知有木有php自带方法可以实现的?

PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
刘奇

这个能返回带标签的内容,应该是你要找的吧?:http://cn2.php.net/manual/zh/domdocument.savehtml.php

如果是XML的话最好用saveXML

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!