我正在尝试使用SimpleXML加载远程URL。如果我在浏览器中输入以下内容;http://api.ean.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=12&apiKey=2hkhej72gxyas3ky6hhjtsga&locale=en_US¤cyCode=USD&customerIpAddress=10.184.2.9&customerUserAgent=Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US;+rv:1.9.2.25)+Gecko/20111212+F
我正在尝试使用SimpleXML加载远程URL。如果我在浏览器中输入以下内容;http://api.ean.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=12&apiKey=2hkhej72gxyas3ky6hhjtsga&locale=en_US¤cyCode=USD&customerIpAddress=10.184.2.9&customerUserAgent=Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US;+rv:1.9.2.25)+Gecko/20111212+F
我想在不使用正则表达式的情况下从表中获取数据。我很喜欢使用simplexml来解析RSS提要,并且想知道它是否可以用于从另一个页面获取表格。例如。使用curl或简单地获取页面file_get_contents();然后用simplexml抓取内容? 最佳答案 您可以使用loadHTML来自DOM模块的函数,然后通过simplexml_import_dom将该DOM导入到SimpleXML中:$html=file_get_contents('http://example.com/');$doc=newDOMDocument();$do
我想在不使用正则表达式的情况下从表中获取数据。我很喜欢使用simplexml来解析RSS提要,并且想知道它是否可以用于从另一个页面获取表格。例如。使用curl或简单地获取页面file_get_contents();然后用simplexml抓取内容? 最佳答案 您可以使用loadHTML来自DOM模块的函数,然后通过simplexml_import_dom将该DOM导入到SimpleXML中:$html=file_get_contents('http://example.com/');$doc=newDOMDocument();$do
我正在使用PHP和simpleXML阅读以下rss提要:http://feeds.bbci.co.uk/news/england/rss.xml我可以获得我想要的大部分信息:$rss=simplexml_load_file('http://feeds.bbci.co.uk/news/england/rss.xml');echo''.$rss->channel->title.'';foreach($rss->channel->itemas$item){echo'link.'">'.$item->title."";echo"".$item->pubDate."";echo"".$item-
我正在使用PHP和simpleXML阅读以下rss提要:http://feeds.bbci.co.uk/news/england/rss.xml我可以获得我想要的大部分信息:$rss=simplexml_load_file('http://feeds.bbci.co.uk/news/england/rss.xml');echo''.$rss->channel->title.'';foreach($rss->channel->itemas$item){echo'link.'">'.$item->title."";echo"".$item->pubDate."";echo"".$item-
我有以下XML:MarkBaker2010-09-01T22:49:33Z2010-09-01T22:48:39Z4PT00H04M20SOpenOffice.org/3.1$Win32OpenOffice.org_project/310m11$Build-9399我正在尝试读取office:document-meta节点以提取其下方的各种元素(dc:creator、meta:creation-date等)以下代码:$xml=simplexml_load_string($gFileData);$namespacesMeta=$xml->getNamespaces(true);$offi
我有以下XML:MarkBaker2010-09-01T22:49:33Z2010-09-01T22:48:39Z4PT00H04M20SOpenOffice.org/3.1$Win32OpenOffice.org_project/310m11$Build-9399我正在尝试读取office:document-meta节点以提取其下方的各种元素(dc:creator、meta:creation-date等)以下代码:$xml=simplexml_load_string($gFileData);$namespacesMeta=$xml->getNamespaces(true);$offi
有没有更优雅的方式将SimpleXML属性转义到数组中?$result=$xml->xpath($xpath);$element=$result[0];$attributes=(array)$element->attributes();$attributes=$attributes['@attributes'];我真的不想为了提取键/值对而循环遍历它。我所需要的只是将它放入一个数组中,然后将其传递。我会认为attributes()默认会这样做,或者至少给出选项。但是我什至无法在任何地方找到上述解决方案,我必须自己弄清楚。我是不是把事情复杂化了?编辑:在确定访问@attributes数组
有没有更优雅的方式将SimpleXML属性转义到数组中?$result=$xml->xpath($xpath);$element=$result[0];$attributes=(array)$element->attributes();$attributes=$attributes['@attributes'];我真的不想为了提取键/值对而循环遍历它。我所需要的只是将它放入一个数组中,然后将其传递。我会认为attributes()默认会这样做,或者至少给出选项。但是我什至无法在任何地方找到上述解决方案,我必须自己弄清楚。我是不是把事情复杂化了?编辑:在确定访问@attributes数组