Muy bien. Gracias spork. , Que ahora funciona, pero ¿cómo puedo ahora convertir desde SimpleXMLElement Object a una matriz?
Lo hice así
$ xml = ( matriz ) $ xml ; pero sinces su supone que es una matriz multidimensional, la más interior "conjuntos" son SimpleXMLElement objetos.
He aquí como este "arreglo" se parece.
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
- )
- )
- )
Este XML es para la prueba de lo que podría ser más adelante...aquí es cómo mi archivo XML parece.
<?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>
y si se necesita ayuda, aquí es cómo mi archivo PHP parece.
<?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
- ?>
Gracias
"Bring forth therefore fruits meet for repentance:" Matthew 3:8