3

Possible Duplicate:
Best XML Parser for PHP

I have an XML code like as given below

<response-code>100</response-code>

<tktname>m1318049ebc11833623372</tktname>

<abc-id>1237829</abc-id>

I want to fetch the tktname from the XMl using PHP

Community
  • 1
  • 1
mark rammmy
  • 1,478
  • 5
  • 27
  • 61
  • 1
    http://stackoverflow.com/questions/3630866/php-parse-xml-string – Haim Evgi Jul 31 '11 at 13:48
  • BTW, that's not valid XML. If you're going to parse it with any standard XML parser, you'll need to add a single tag surrounding the whole thing. – JW. Jul 31 '11 at 16:08

3 Answers3

3

What about http://www.php.net/manual/en/simplexml.examples-basic.php?

Krab
  • 2,118
  • 12
  • 23
1
$xml = new SimpleXMLElement('<test>'.$yourcode.'</test>');
print $xml->tktname;
RiaD
  • 46,822
  • 11
  • 79
  • 123
1

You want to use xml_parse to create your own parser: http://www.php.net/manual/de/intro.xml.php. xml_parse is part of php so it's likely to be installed even on shared hoster. Or you want to use DOM-XML a php extension: http://www.php.net/manual/en/book.domxml.php

Micromega
  • 12,486
  • 7
  • 35
  • 72