Ei kuvausta

helpers.php 397B

12345678910111213141516
  1. <?php
  2. if (!function_exists('getInfoFromXml')) {
  3. /**
  4. * 读取xml字符串,获取对应数据
  5. * @return string
  6. */
  7. function getInfoFromXml($xmlStr, $field)
  8. {
  9. $xml_tree = new \DOMDocument();
  10. $xml_tree->loadXML($xmlStr);
  11. $array_e = $xml_tree->getElementsByTagName($field);
  12. $info = $array_e->item(0)->nodeValue;
  13. return $info;
  14. }
  15. }