php - Using getElementsByTagName in Wordpress -
php - Using getElementsByTagName in Wordpress -
i have simple script read xml file:
<?php $xml_data=wp_remote_get("http://example.com/connectioncounts"); //$doc = new domdocument(); //$doc->load($xml_data); $wms = $xml_data->getelementsbytagname('tag'); $currentlistener = $wms->item(0)->getelementsbytagname("connectionscurrent")->item(0)->nodevalue; $listenerhits = $wms->item(0)->getelementsbytagname("connectionstotal")->item(0)->nodevalue; echo "current listener: $currentlistener<br> total hits: $listenerhits"; ?> i using wp_remote_get wordpress doesn't seem file_get_contents referred this previous question.
the problem when run code error:
fatal error: phone call undefined method wp_error::getelementsbytagname() in /home/user/public_html/test/wp-content/themes/headway/library/common/functions.php(405) : eval()'d code on line 10 i figured similar how wordpress doesn't file_get_contents, maybe there function getelementsbytagname?
php wordpress xml-parsing
Comments
Post a Comment