Home »
Imported messages »
comp.lang.php »
Problem creating XML file
Problem creating XML file [message #179556] |
Wed, 07 November 2012 12:42  |
Sarah
Messages: 30 Registered: December 2010
Karma: 0
|
Member |
|
|
I need to create this structure
<docAzione>
<documento nome="Prova1.txt" />
<documento nome="Prova2.txt" />
</docAzione>
I tried doing:
$docAzione = $azione->addChild('docAzione');
while ($row_files = mysql_fetch_array($result_files,MYSQL_ASSOC)) {
......
$docAzione->addChild('documento', $row_files{'fm_nomefile'});
But result is:
<docAzione>
<documento>Prova1.txt</documento>
<documento>Prova2.txt</documento>
</docAzione>
(wrong)
So I tried with
$docAzione->addAttribute('nome', $row_files{'fm_nomefile'});
And I show:
<docAzione nome="Prova1.txt"/>
(wrong)
Where is it my error?
Thanks
|
|
|
|
|
|
|
Re: Problem creating XML file [message #179567 is a reply to message #179565] |
Thu, 08 November 2012 00:50  |
Michael Fesser
Messages: 215 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
.oO(dandi(dot)box(at)gmail(dot)com)
> Why are you talking about to create an empty children?
>
> I need this:
>
> <docAzione>
> <documento nome="Prova1.txt" />
> <documento nome="Prova2.txt" />
> </docAzione>
>
> Why do you see "empty children"?
Because your <documento/> are empty children, they don't have any
content. 'nome' is an attribute, but the elements themselves are empty.
This is an empty element:
<foo/> or <foo></foo>
This is a non-empty element:
<foo>bar</foo>
So, for each row from your database, create an empty 'documento'
element, add a 'nome' attribute to it with the value from the DB and
then append the whole thing to the root 'docAzione' element.
Micha
--
http://mfesser.de/
Fotos | Blog | Flohmarkt
|
|
|
Goto Forum:
Current Time: Fri Feb 28 04:00:01 GMT 2025
Total time taken to generate the page: 0.04662 seconds