0

Fetch city from this xml document http://api.hostip.info/

so i used html dom parser.

if i used gml:name to get city name i got city name as well as host id string. how to get only city name from this site?

Jaydipsinh
  • 491
  • 1
  • 9
  • 27
  • load it in html dom and then using xpath call nodeValue to get only name of city – Sohail Ahmed Nov 06 '12 at 11:56
  • can u write code for it ? because i don't have that much knowledge. – Jaydipsinh Nov 06 '12 at 11:57
  • this is my code: $html = file_get_html('http://api.hostip.info/'); foreach($html->find('gml:name') as $element) echo $element; but here i got city name as well as hotid string – Jaydipsinh Nov 06 '12 at 11:59
  • hey Dark Wish, if i used countryName instead of gml:name in find() then i got country name, it works fine. so i think there is a problem with : only – Jaydipsinh Nov 06 '12 at 12:04
  • sorry for late reply Get help from this [link](http://www.w3schools.com/xml/tryit.asp?filename=tryxml_parsertest)
    are you pakistani?
    – Sohail Ahmed Nov 06 '12 at 12:27
  • i already had look on that page, but instead of that xml file when i try to add url inside get method its not work.. – Jaydipsinh Nov 06 '12 at 12:45
  • anyway using split i remove that hostid string. that is only solution i got. and ha i m Indian. – Jaydipsinh Nov 06 '12 at 12:46

0 Answers0