Posted By

ollie101 on 07/19/10


Tagged

php xml tag


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

ollie101
Vordreller
osirisinternet
convergine


Get the contents of a specified tag from an XML file in PHP


 / Published in: PHP
 

URL: http://www.olliesilviotti.co.uk

Simple piece of PHP to get the contents of a specified tag from an XML file and return it

  1. //Get the contents of a specified tag ($tag) of the specified XML file ($xmlFile)
  2. function getXmlData($xmlFile, $tag)
  3. {
  4. $output = substr($xmlFile, strpos($xmlFile, "<".$tag.">") + strlen("<".$tag.">"),
  5. strpos($xmlFile, "</".$tag.">")- strpos($xmlFile, "<".$tag.">") - strlen("<".$tag.">"));
  6. return $output;
  7. }

Report this snippet  

You need to login to post a comment.