Page 1 of 1

xml to the format of array i have given..how to proceed?

Posted: Thu Aug 16, 2007 3:09 pm
by smilesmita
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi there:
i have an xml file which kind of looks like this[as an example i have kept it simple].I want to conver this xml to the array format shown below.dont know how to do it..please help.after i get this array format then it will be easy for me to insert these records in database table by iterating:
[syntax="xml"]<xml version.....>
<SubscriptionEvents>
 <subscriptionFile>
  <filename>filename1</filename>
  <statustype>
     <Code>
       <Date>date1</Date>
       <Time>time1</Time>
     </Code>
  <statustype>
  <Manifest>
      <address>address1</address>
  </Manifest>
 </subscriptionfile>

 <subscriptionFile>
  <filename>filename2</filename>
  <statustype>
     <Code>
       <Date>date2</Date>
       <Time>time1</Time>
     </Code>
  <statustype>
  <Manifest>
      <address>address2</address>
  </Manifest>
 </subscriptionfile>

<SubscriptionEvents>
Want an output like this:[/syntax]

Code: Select all

Array
(
 [subscriptionEvents]=>
 [details] => Array
        (
            [0] => Array
                (
                    Subscriptionfile=>
                    filename=>filename1
                     statustype=>
                    Code=>
                    Date=>date1
                    Time=>time1
                    Manifest=>
                    address=>address1
                    ) 
            [1] => Array
               (   
                    Subscriptionfile=>
                    filename=>filename2
                     statustype=>
                    Code=>
                    Date=>date2
                    Time=>time2
                    Manifest=>
                    address=>address2
               )
         )
)

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Aug 16, 2007 5:09 pm
by feyd
Have you... looked at the XML handling functions supported (and loaded) by your host? If they haven't loaded any, there are libraries out there for it as well.