如题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <code class = "lang-DOM" >DOMElement Object
(
[tagName] => div
[schemaTypeInfo] =>
[nodeName] => div
[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] => div
[baseURI] =>
[textContent] =>
Article Name
Contents of article
One
Two
Three
Four
Five
)
</code>
|
Nach dem Login kopieren
Nach dem Login kopieren
用textContent获取的都是不带标签的内容...不知有木有php自带方法可以实现的?
回复内容:
如题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <code class = "lang-DOM" >DOMElement Object
(
[tagName] => div
[schemaTypeInfo] =>
[nodeName] => div
[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] => div
[baseURI] =>
[textContent] =>
Article Name
Contents of article
One
Two
Three
Four
Five
)
</code>
|
Nach dem Login kopieren
Nach dem Login kopieren
用textContent获取的都是不带标签的内容...不知有木有php自带方法可以实现的?
这个能返回带标签的内容,应该是你要找的吧?:http://cn2.php.net/manual/zh/domdocument.savehtml.php
如果是XML的话最好用saveXML
。