View Single Post
  #1 (permalink)  
Old 10-28-2007, 10:54 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,122
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
XML_Parse_Into_Struct()

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
PHP Code:
<?php
//invalid xml file
$xmlfile 'test.xml';
$xmlparser xml_parser_create();

// open a file and read data
$fp fopen($xmlfile'r');
$xmldata fread($fp4096);

xml_parse_into_struct($xmlparser,$xmldata,$values);

xml_parser_free($xmlparser);
print_r($values);
?>
Here's what I found after a little bit of research, this method can return me:

Code:
Array
(
[0] => Array
  (
  [tag] => NOTE
  [type] => open
  [level] => 1
  [value] =>
  )
  [1] => Array
    (
    [tag] => TO
    [type] => complete
    [level] => 2
    [value] => Tove
    )
[2] => Array
  (
  [tag] => NOTE
  [value] =>
  [type] => cdata
  [level] => 1
  )
  [3] => Array
    (
    [tag] => FROM
    [type] => complete
    [level] => 2
    [value] => Jani
    )
[4] => Array
  (
  [tag] => NOTE
  [value] =>
  [type] => cdata
  [level] => 1
  )
  [5] => Array
    (
    [tag] => HEADING
    [type] => complete
    [level] => 2
    [value] => Reminder
    )
[6] => Array
  (
  [tag] => NOTE
  [value] =>
  [type] => cdata
  [level] => 1
  )
  [7] => Array
    (
    [tag] => BODY
    [type] => complete
    [level] => 2
    [value] => Don't forget me this weekend!
    )
[8] => Array
  (
  [tag] => NOTE
  [value] =>
  [type] => cdata
  [level] => 1
  )
[9] => Array
  (
  [tag] => NOTE
  [type] => close
  [level] => 1
  )
)
But how do you access each of them? That's what I'm confused lol.. I'm not sure on how does this work? Please give me easy example, thanx a lot!!!

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote