473,320 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with converting XML string into array

1
Hi I'm trying to convert the XML file into associative array by using the following code

Expand|Select|Wrap|Line Numbers
  1. $xmlUrl = '../products.xml';
  2. $xmlStr = file_get_contents($xmlUrl); 
  3. $xmlObj = simplexml_load_string($xmlStr);  print_r ($xmlObj);exit;
  4. $arrXml = objectsIntoArray($xmlObj);
and product.xml containing

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <products>
  3.   <product>
  4.     <sku>p750h3</sku>
  5.     <category>Plans: Vodafone Unlimited Cap</category>
  6.     <price>$0</price>
  7.     <totalmonthlycost>$129</totalmonthlycost>
  8.     <totalmincost>$3096</totalmincost>
  9.     <upfront>$0</upfront>
  10.     <imageurl>http://store.vodafone.com.au/Images/Upload/nokia-6260-slide-front_118x307.png</imageurl>
  11.     <threedurl>http://store.vodafone.com.au/handset-nokia-6260-slide.aspx#3d</threedurl>
  12.     <smallimageurl>http://store.vodafone.com.au/Images/Upload/nokia-6260-slide-front_23x60.png</smallimageurl>
  13.     <name>Nokia 6260 Slide $129 Unlimited Cap - 24 Months</name>
  14.     <description></description>
  15.     <ctppage>http://store.vodafone.com.au/handset-nokia-6260-slide.aspx</ctppage>
  16.     <features>
  17.       <![CDATA[
  18.                 Exclusive to Vodafone, this advanced all &ndash; in - one device has advanced web and navigation features plus a handy 360 degree Navi key to help you stay in control.<br/><ul>
  19.         <li>5 MP camera with Carl Zeiss optics and Flash</li>
  20.         <li>WiFi, HSDPA and HSUPA</li>
  21.         <li>Integrated GPS Navigation</li>
  22.         <li>3G (<a href="/whatis3g-popup.aspx" onclick="window.open(this.href,'','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=600,height=590,status'); return false"><u>What's this?</u></a>)</li>
  23.         </ul>
  24.             ]]>
  25.     </features>
  26.     <available>Yes</available>
  27.     <shippingcost>$0.0</shippingcost>
  28.     <dimensions></dimensions>
  29.     <manufacturer>Nokia</manufacturer>
  30.     <modelnumber>6260 Slide</modelnumber>
  31.     <currency>AUD</currency>
  32.     <devicekeypoints>&lt;ul&gt;
  33.  
  34.       &lt;li&gt;5 MP camera with Carl Zeiss optics and Flash&lt;/li&gt;
  35.       &lt;li&gt;WiFi, HSDPA and HSUPA&lt;/li&gt;
  36.       &lt;li&gt;Integrated GPS Navigation&lt;/li&gt;
  37.       &lt;li&gt;3G (&lt;a href="/whatis3g-popup.aspx" onclick="window.open(this.href,'','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=600,height=590,status'); return false"&gt;&lt;u&gt;What's this?&lt;/u&gt;&lt;/a&gt;)&lt;/li&gt;
  38.  
  39.       &lt;/ul&gt;</devicekeypoints>
  40.     <deviceTagline></deviceTagline>
  41.     <deviceColor>Black</deviceColor>
  42.     <deviceSpecialOffers></deviceSpecialOffers>
  43.     <deviceMonthlyHandsetCost>0.0</deviceMonthlyHandsetCost>
  44.     <deviceRecommendedPlan>$129 Unlimited Cap - 24 Months</deviceRecommendedPlan>
  45.     <deviceOverallRating></deviceOverallRating>
  46.     <plan>
  47.       <term>24</term>
  48.       <monthlyCapCost>$129</monthlyCapCost>
  49.       <getMonthly>
  50.         <![CDATA[Monthly credit amount - UNLIMITED<br/>Monthly data - 4GB<sup>3</sup><br/>Vodafone to Vodafone Calls - UNLIMITED<br/>Also includes - Voicemail retrieval <br/><br/>Flexi credit amount - NA<br/>Standard national voice calls - UNLIMITED<br/>Standard txt and pxt - UNLIMITED<br/>]]>
  51.       </getMonthly>
  52.     </plan>
  53.   </product>...etc
but it returns a error message as follows

Expand|Select|Wrap|Line Numbers
  1. Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : String not started expecting ' or " in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24
  2.  
  3. Warning: simplexml_load_string() [function.simplexml-load-string]: <?xml version=\"1.0\" encoding=\"utf-8\"?> in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24
  4.  
  5. Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24
  6.  
  7. Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Malformed declaration expecting version in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24
  8.  
  9. Warning: simplexml_load_string() [function.simplexml-load-string]: <?xml version=\"1.0\" encoding=\"utf-8\"?> in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24
  10.  
  11. Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in D:\EBU\xampp\htdocs\biglinks\include\productUpdate.php on line 24......etc
I am trying to fix this issue whole day and searching solution over the net but i could not get . Please let me know the reason?
Feb 18 '11 #1
0 1248

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Walter Zydhek | last post by:
Is it possible to convert an ArrayList to a string array? I have a routine that takes a string array as a parameter, converts it to an ArrayList for manipulation purposes, and now I need to...
8
by: Jeff Johnson | last post by:
Hi, I've begun converting an ASP site over to .NET and I'm a novice at both the new platform as well as C#. I have a COM+ object that returns a string array when it is called. The size of...
2
by: Dick Swager | last post by:
The following code is from a solution with a C++ project and a C# project. The C++ project creates a managed array and the C# project tries to use it. But I am having a 'System.ValueType' to...
4
by: diDE | last post by:
I want to convert a managed string array f.e. array<string^>^ Texts; // Elements 0: "ABC", 1: "HJO" to a TCHAR** or wchar_t** any ideas?
5
by: Andrew Banks | last post by:
Can anyone see aproblem with this line of code string rolelistarray = rolelist.ToArray(GetType(System.String)); I'm getting a problem with the GetType(System.String) section
0
by: wrytat | last post by:
In one web page, I redirect it to "prtDelReq.aspx?prtindex=0A2A3A8" after the user click the button. The prtindex actually contains many integers separated by 'A'. On the prtDelReq page, I use...
3
by: Nikolay Petrov | last post by:
I have a string array, which I need to save to a file. The array may grow to thousands of elements. My question is what is the fastest way to save it as text file? The StreamWriter accepts String...
5
by: Chuck Cobb | last post by:
I'm having a problem converting an array to a collection. The code I'm using looks like the following: CustomerInfo cArray; Collection<CustomerInfo> cCollection = new...
7
by: kmitchell00 | last post by:
I am coding in Coldfusion MX7 and using Javascript for some of the functionality. The basic functionality I'm coding is, based on a value the user chooses from a dropdown box, I populate address...
2
by: shahiz | last post by:
basically im having null pointer exception //read an inputstream is = new DataInputStream(new FileInputStream("test.mpg")); loadBytes(is); //pass it as a datasource for the player public...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.