Jump to content
Fórum Script Brasil
  • 0

Problema Ao Ler Xml Com Dom


senna

Question

ola galera to com pequeno probleminha ao ler um xml

o codigo é o seguinte

<?php
  $doc = new DOMDocument();
  $doc->load( 'host.xml' );
  
  $books = $doc->getElementsByTagName( "Hostip" );
  foreach( $books as $book )
  {
  $authors = $book->getElementsByTagName( "gml:name" );
  $author = $authors->item(0)->nodeValue;
  
  $publishers = $book->getElementsByTagName( "countryName" );
  $publisher = $publishers->item(0)->nodeValue;
  
  $titles = $book->getElementsByTagName( "countryAbbrev" );
  $title = $titles->item(0)->nodeValue;
  
  echo "$title - $author - $publisher\n";
  }
  ?>
eu peguei ele em http://www-128.ibm.com/developerworks/open...y/os-xmldomphp/ (ae nem renomiei as variaveis nem nada) e to tentando adapta pra outro xml, só q a informação q eu mais queria pegar dele não to conseguindo q é a parte "gml:name", as outras porem são impressas, aqui vai um xml q eu to tentando ler.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<HostipLookupResultSet version="1.0.0" xmlns="http://www.hostip.info/api" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hostip.info/api/hostip-1.0.0.xsd">
 <gml:description>This is the Hostip Lookup Service</gml:description>
 <gml:name>hostip</gml:name>
 <gml:boundedBy>
  <gml:Null>inapplicable</gml:Null>
 </gml:boundedBy>
 <gml:featureMember>
  <Hostip>
   <gml:name>Sugar Grove, IL</gml:name>
   <countryName>UNITED STATES</countryName>
   <countryAbbrev>US</countryAbbrev>
   <!-- Co-ordinates are available as lng,lat -->
   <ipLocation>
    <gml:PointProperty>
     <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
      <gml:coordinates>-88.4588,41.7696</gml:coordinates>
     </gml:Point>
    </gml:PointProperty>
   </ipLocation>
  </Hostip>
 </gml:featureMember>
</HostipLookupResultSet>

acredito q seja algum problema com o ":" se puderem dar um help

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.5k
×
×
  • Create New...