23490 Posts in 18996 Topics by 2878 members
Page: 1 2
|Go to End|
28 February 2009 at 2:17pm
Jardiamj, if you are using SS2.3 it already has a method to do this. Convert::xml2array($xmlFile) which will return an array and it handles attributes as well.
28 February 2009 at 5:00pm Last edited: 28 February 2009 5:02pm
Thanks again Willr, I tried to use it; but I don't know what I was doing wrong that it didn't work, I got tired of being trying to figure it out so I decided to build my own function, I don't need something so complex any way. I also modified my function so it handles attributes as well but I'm not using it now.
I will give a try to the method Convert::xml2array again. I think I know now what I was doing wrong, I'm new to everything related with web designing. I'm a bachelor in agriculture, but the web is a good tool and I want to use it. Silver Stripe has been very useful for me, in a short time I have a decent looking website and getting data from a external MySQL Database.
I have to say that Silver Stripe is great, for people like me with no so much knowledge in PHP programing or even web designing.
31 August 2010 at 12:35am
How do you convert into DataObject?
31 August 2010 at 9:18pm
biapar - If your array has the Keys which match the dataobject field names then you can simply pass the array you get from Convert::xmlToArray() into the dataobject constructor. Like
$data = array('Field' => 'Value', 'SomeOtherField' => 'Hello');
$object = new MyDataObject($data);
echo $object->Field; // echos 'Value'
echo $object->SomeOtherField; // echos 'Hello'
As long as your xml keys match your dataobject fields you won't have to massage any of the data.
1 September 2010 at 9:48am Last edited: 1 September 2010 9:48am
Never knew you can do that, you learn something new every day .
I have done similar tasks before. I needed to import XML exported from Access and convert it into Blog posts. I found it was easiest to create a build task, and access it from:
Then i could just put all my logic in something isolated from the rest of the site. I suppose you could probably link that to a cron job, if you have SS 2.4?
2 September 2010 at 4:09am Last edited: 2 September 2010 4:13am
Ok..I create function with xml2array and work, but this is the xml source
- <car id="1510834">
<version>1.2 16V TCE GT</version>
and this is array ( a part )
1.2 16V TCE GT
How use it as dataobject?
I've more car nodes and each car node has more attributes.
Page: 1 2
|Go to Top|