473,465 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SimpleXMLElement Object into array

How do I put the value of an SimpleXMLElement Object into any array

If $title is SimpleXMLElement Object ( [0] =Mother )

how do I get "Mother" and put it in an array ? ;

if I echo $title, it says "Mother" but if I put it in an array
$myarray=array($title);
the array is Array ( [0] =SimpleXMLElement Object ( [0] =>
Mother ) )
I don't want that I want
Array ( [0] =>Mother) )
Oct 2 '08 #1
2 16498
rodeored skrev:
How do I put the value of an SimpleXMLElement Object into any array
You might need to type cast the values (either implicit or explicit).
if I echo $title, it says "Mother" but if I put it in an array
$myarray=array($title);
It looks like you can directly cast $title to be an array:
$myarray = (array)$title;

- for other purposes you could also consider:
$myarray = array( (string)$title );

Regards

Jonathan
Oct 3 '08 #2
..oO(rodeored)
>How do I put the value of an SimpleXMLElement Object into any array

If $title is SimpleXMLElement Object ( [0] =Mother )

how do I get "Mother" and put it in an array ? ;

if I echo $title, it says "Mother" but if I put it in an array
$myarray=array($title);
the array is Array ( [0] =SimpleXMLElement Object ( [0] =>
Mother ) )
I don't want that I want
Array ( [0] =>Mother) )
To access a SimpleXMLElement's content you have to cast it to a string.
Sometimes this happens automatically, for example if you print it out or
use any other function that accepts strings values, in cases like above
you have to cast explicitly.

Micha
Oct 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Brian P | last post by:
I am getting an invalid cast exception when I try to take an ArrayList with datetime values and use the ToArray method to create an object array. I need to use an object array becase I'm working...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
2
by: Niklas | last post by:
Hi I'm creating a .NET dll, which I will use in VB 6. I have no problem declaring methods, which will take a single Object, String, Integer and so on as a parameter. I manage even to transfer...
6
by: Christian Blackburn | last post by:
Hi Gang, I can't seem to figure out how to create an object array in VB.NET 2003. In VB6 you would just select an object copy and paste it and that was that. I don't know why in the heck they...
4
by: kin | last post by:
After a I read Walkthrough: Connecting to Data in Objects (http://msdn2.microsoft.com/en-us/library/ms171892.aspx#Mtps_DropDownFilterText). I still have project on that. My School project...
2
by: jay1_z | last post by:
Here is my code in VB: Return Me.Document.GetItemValue("Subject")(0) The "GetItemValue" method returns an 'object' array, and the first item in the array is a string. This works for me in VB...
1
by: comp.lang.php | last post by:
array_walk($result, create_function('$a, $b', 'return (strtolower($a->{$section . "_name"}) < strtolower($b->{$section . "_name"}));'), $section); I thought this would sort an object array by...
4
by: buzzluck68 | last post by:
Hello, I am having trouble upgrading my VB apps to .net. When i started at my company there was a dll created here in vb6, and i need to use that dll for many functions that would take too much...
1
Samishii23
by: Samishii23 | last post by:
I was wondering, since I'm about to embark on an heavy object array project. As I was studying arrays, I was wondering if Object arrays are treated the same? like: var arr1 = ; arr1.push(1,2,3);...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.