我一直在尝试使用 SimpleXML ,但是它没有似乎不喜欢看起来像这样的XML:
I've been trying to use SimpleXML, but it doesn't seem to like XML that looks like this:
<xhtml:div>sample <xhtml:em>italic</xhtml:em> text</xhtml:div>那么哪个库将处理看起来像这样的标签(其中带有冒号)?
So what library will handle tags that look like that (have a colon in them)?
推荐答案假设您有这样的xml.
Say you have some xml like this.
<xhtml:div> <xhtml:em>italic</xhtml:em> <date>2010-02-01 06:00</date> </xhtml:div>您可以这样访问"em":$xml->children('xhtml', true)->div->em;
You can access 'em' like this: $xml->children('xhtml', true)->div->em;
但是,如果您想要日期字段,则此操作:$xml->children('xhtml', true)->div->date; 将无法工作,因为您被困在xhtml命名空间中.
however, if you want the date field, this: $xml->children('xhtml', true)->div->date; wont work, because you are stuck in the xhtml namespace.
您必须再次执行'children'才能返回默认名称空间:
you must execute 'children' again to get back to the default namespace:
$xml->children('xhtml', true)->div->children()->date;更多推荐
PHP库用于使用标记名称中的冒号来解析XML?
发布评论