mercredi 29 avril 2015

How can I get a xml file into a variable and concatenate 2 nodes?

I already read/saw simplexml_load_string() to load a xml string into a variable.

But how can I load a xml file into a variable?

file.xml:

<note>
    <FirstName>Ana</FirstName>
    <LastName>Ivonic</LastName>
    <heading>Resume</heading>
    <body>Interview</body>
</note>

How can I print the first and last name as full name concatenated ?

So I already have this to load a string:

$XML = simplexml_load_string($string);

And then I use: $XML->FirstName.

Now how can I load a xml file (not a string) and concatenate the first and last name and print it?

Aucun commentaire:

Enregistrer un commentaire