Converstion of Data from XML To php Array

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
habib009pk
Forum Commoner
Posts: 43
Joined: Sun Jul 05, 2009 11:28 pm

Converstion of Data from XML To php Array

Post by habib009pk »

Dear Friends hi,

I am facing a problem I am extracting the data from the other server in the form of XML, now i want to save that data in my database tables, i am using a scheme to covert that into an array from that xml data. For this first of all i create an xml text file, that xml file than changed into an array. As this xml file which i am getting from the other server has lot of data. So when i create the xml text file full data from the xml is not put on the xml text file, it has been cut off between the center.

The code i am using is:

$fh = fopen("myfile.xml", "w");
fwrite($fh, $xml);

This $xml has all the data which i am getting from the other server.

Please give me any specific way which is usefull for me regarding the creation of xml text file. and i got the full xml text data in that xml text file.

Best Regards and Very Thankful.
Last edited by habib009pk on Mon Jul 06, 2009 1:25 am, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Converstion of Data from XML To php Array

Post by Christopher »

There are many ways to deal with XML in php:

http://us.php.net/manual/en/refs.xml.php

I would recommend starting with SimpleXML.
(#10850)
habib009pk
Forum Commoner
Posts: 43
Joined: Sun Jul 05, 2009 11:28 pm

Re: Converstion of Data from XML To php Array

Post by habib009pk »

Thank for your guidance,

but i would like to say that everything perfectly working, the data can be extracted, the file can also be created, array has been generated correctly, even the data can also be saved in databases perfectly. but the problem is that when i create the xml file the text file cut off between the center, some think like that:

<item>
<lot_id>27695790</lot_id>
<lot_date>2009-07-12 23:00:00</lot_date>
<bid>47415970</bid>
<company>TOYOTA</company>
<model_year_en>2002</model_year_en>
<model_name_en>ESTIMA L</model_name_en>
<model_detail></model_detail>
<grade_en>AERAS</grade_en>
<model_type_en>ACR40W</model_type_en>
<mileage_en>81</mileage_en>
<mileage_num>81</mileage_num>
<inspection_en></inspection_en>
<equipment_en>AC PS PW SR aluminium 4WD 1 owner</equipment_en>
<transmission_en>CAT</transmission_en>
<awd>4</awd>
<left_hd></left_hd>
<truck></truck>
<special_num></special_num>
<special></special>
<displacement>2400</displacement>
<displacement_num>2400</displacement_num>
<start_price_en>730</start_price_en>
<start_price_usd>7604</start_price_usd>
<end_price_en>730</end_price_en>
<end_price_usd>7604</end_price_usd>
<average_price></average_price>
<color_en>PEARL</color_en>
<color_basic_ref>9</color_basic_ref>
<scores_en>4</scores_en>
<result_en>available</result_en>
<result_num>5</result_num>
<chassis_no></chassis_no>
<company_ref>9</company_ref>
<model_ref>789</model_ref>
<auct_ref>109</auct_ref>
<auct_system_ref>GAO_STOCK</auct_system_ref>
<auction_name>GAO Stock</auction_name>
<pics_urls>#http://dragon.aleado.com/p3/PicGetter?y ... /pics_urls>
</item>
<item>
<lot_id>27695789</lot_id>
<lot_date>2009-07-12 23:00:00</lot_date>
<bid>47409921</bid>
<company>TOYOTA</company>
<model_year_en>2002</model_year_en>
<model_name_en>COROLLA RUNX</model_name_en>
<model_detail></model_detail>
<grade_en>X LIMITED</grade_en>
<model_type_en>NZE121</model_type_en>
<mileage_en>40</mileage_en>
<mileage_num>40</mileage_num>
<inspec
And this will effect me on my full data extration.
I would like to ask that if there is any size limition for the creation of xml file.

Best Regards
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Converstion of Data from XML To php Array

Post by Christopher »

You might need to give the length argument to fwrite().
(#10850)
Post Reply