XML Parsing using PHP

Discussion in 'PHP' started by kks_krishna, Dec 21, 2006.

  1. #1
    HI,

    I want to know about the XML parsing in PHP.
    If anyone is having sample codes and examples, please post it here.

    Thanks,
    Krishna Srinivasan
     
    kks_krishna, Dec 21, 2006 IP
  2. yugu

    yugu Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Download from http://xmlsapiens.org their free cms. It includes xml parsing function.
    Really good starting point.
     
    yugu, Dec 21, 2006 IP
  3. void

    void Peon

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I use this to parse data from an external site retrieved using curl. Look here for explanations... http://www.php.net/xml_parse_into_struct

    
      	$xml_parser = xml_parser_create();
      	xml_parse_into_struct($xml_parser, $returnData, $vals, $index);
      	xml_parser_free($xml_parser);
      	
      	//create an associative array from the return structure
      	$nNumTags = count($vals);
      	
      	for ($nIndex = 0; $nIndex < $nNumTags; $nIndex++)
      	{
      		$strTagName = $vals[$nIndex]['tag'];
      		$strValue = $vals[$nIndex]['value'];
      		$strLevel = $vals[$nIndex]['level'];
      		if($strLevel == "2")
      		{
      			$aResult[$strTagName] = $strValue;
      		}
      	}
    		
    	print_r($aResult);
    PHP:
     
    void, Dec 21, 2006 IP
  4. mani

    mani Peon

    Messages:
    679
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    www.php.net and read their manual for xml parsing functions...
     
    mani, Dec 21, 2006 IP