希望这很简单。
在PHP中,我试图抓取一些RSSfeed。有时,RSS提要没有正确更新/填充,但它不是一个空文件。我有以下代码:
$xml = simplexml_load_file("feed-url-here");
if ($xml != "") {
if (strlen($xml) > 600) {
perform some actions here;
}
}
这不起作用。有没有一种快速的方法来评估xml的strlen?
希望它不涉及解析提要本身。
非常感谢!
我不确定你想要实现什么,无论如何,如果你想获得代表xml的字符串的长度,你可以这样做:
$xml = simplexml_load_file("feed-url-here");
if ($xml != "") {
if (strlen($xml->asXML()) > 600) {
perform some actions here;
}
}