// States: // // 'out' // '' // '!' // '![' // '![C' // '![CD' // '![CDAT' // '![CDATA' // 'in' // ']' // ']]' // // (Yes, the states a represented by strings.) // $state = 'out'; $a = str_split($xml); $new_xml = ''; foreach ($a AS $k = $v
最近发现,总是有alert发出来, 说是simplexml解析出错。
发现是原来有xml的数据是]]] >. 出现了连续的3个], 造成上面的解析函数不能处理。
而且这个问题很难修正, 你不知道下次会不会有4, 5个]出现。
所以决定还是将这段解析 的代码换成DOM XML,本身 DOM的处理还是比较简单的,
包含DOMElement, DOMDocument, DOMNodeList, DOMNode几个 component.
对于 DOMNode有nodeValue, nodeType, nodeName的成员函数。
首先先用loadXML将string转化为DOMDocument对像, 再用getElementsByTagName转化为DOMNodeList对像, 再使用->item(0)转化为DOMNOde, 然后就可以使用上面的三种方法了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
