Alright. Thanks spork. That now works, but how do I now convert it from SimpleXMLElement Object to an array?
I did that like this
$xml = (array) $xml; but sinces it's supposed to be a multidimensional array, the most inner "arrays" are SimpleXMLElement Object.
Here is how that "array" looks like.
Array
(
[mail] => Array
(
[0] => SimpleXMLElement Object
(
[to] => Bogey
[from] => Runwin2
[subject] => Welcome
[body] => Welcome to wedevoy.com
)
[1] => SimpleXMLElement Object
(
[to] => Bogey
[from] => Runwin2
[subject] => Welcome
[body] => Welcome to wedevoy.com
)
[2] => SimpleXMLElement Object
(
[to] => Bogey
[from] => Runwin2
[subject] => Welcome
[body] => Welcome to wedevoy.com
)
[3] => SimpleXMLElement Object
(
[to] => Bogey
[from] => Runwin2
[subject] => Welcome
[body] => Welcome to wedevoy.com
)
)
)
- Array
- (
- [mail] => Array
- (
- [0] => SimpleXMLElement Object
- (
- [to] => Bogey
- [from] => Runwin2
- [subject] => Welcome
- [body] => Welcome to wedevoy.com
- )
- [1] => SimpleXMLElement Object
- (
- [to] => Bogey
- [from] => Runwin2
- [subject] => Welcome
- [body] => Welcome to wedevoy.com
- )
- [2] => SimpleXMLElement Object
- (
- [to] => Bogey
- [from] => Runwin2
- [subject] => Welcome
- [body] => Welcome to wedevoy.com
- )
- [3] => SimpleXMLElement Object
- (
- [to] => Bogey
- [from] => Runwin2
- [subject] => Welcome
- [body] => Welcome to wedevoy.com
- )
- )
- )
This XML is for the test for what it might be later on... here is how my XML file looks like.
<?xml version="1.0" encoding="ISO-8859-1"?>
<mailer>
<mail>
<to>Bogey</to>
<from>Runwin2</from>
<subject>Welcome</subject>
<body>Welcome to wedevoy.com</body>
</mail>
<mail>
<to>Bogey</to>
<from>Runwin2</from>
<subject>Welcome</subject>
<body>Welcome to wedevoy.com</body>
</mail>
<mail>
<to>Bogey</to>
<from>Runwin2</from>
<subject>Welcome</subject>
<body>Welcome to wedevoy.com</body>
</mail>
<mail>
<to>Bogey</to>
<from>Runwin2</from>
<subject>Welcome</subject>
<body>Welcome to wedevoy.com</body>
</mail>
</mailer>
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <mailer>
- <mail>
- <to>Bogey</to>
- <from>Runwin2</from>
- <subject>Welcome</subject>
- <body>Welcome to wedevoy.com</body>
- </mail>
- <mail>
- <to>Bogey</to>
- <from>Runwin2</from>
- <subject>Welcome</subject>
- <body>Welcome to wedevoy.com</body>
- </mail>
- <mail>
- <to>Bogey</to>
- <from>Runwin2</from>
- <subject>Welcome</subject>
- <body>Welcome to wedevoy.com</body>
- </mail>
- <mail>
- <to>Bogey</to>
- <from>Runwin2</from>
- <subject>Welcome</subject>
- <body>Welcome to wedevoy.com</body>
- </mail>
- </mailer>
and if it is needed for help, here is how my php file looks like.
<?php
$xml = simplexml_load_file('file.xml');
$xml = (array) $xml;
echo "<pre>";
print_r($xml);
echo "</pre>";
print_r($xml['mail']['0']['to']); // Doesn't print anything
?>
- <?php
- $xml = simplexml_load_file('file.xml');
- $xml = (array) $xml;
- echo "<pre>";
- print_r($xml);
- echo "</pre>";
- print_r($xml['mail']['0']['to']); // Doesn't print anything
- ?>
Thanks
"Bring forth therefore fruits meet for repentance:" Matthew 3:8