PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
im trying to create a client program that uses nusoap to get weather information in XML format from a server site. now i have the client accessing the xml but the only problem is is that some of the xml tags have a "-" in them. for example here is a line of the xml:
to access the wind speed i need to create an array called wind-speed but php doesnt allow for dashes in varliable or array names!!!! anyone know a solution to this problem???
yes but i have to create an array called "wind-speed" in order to access the information. the "wind-speed" tag is part of the xml dowloaded from the server and i cant change it.
Please be more specific. Have you already written code that is not behaving as you would like? If you have, please post some of the relevant code here so I can take a look at it.
To be honest with you, I am not really sure why you are so insistent on having dashes so I want to see what can be done and what you have done.
have you not read my first post???
im getting xml from a server using a client that i have written. somebody else has written the xml, i cant change it as it resides on the server. for some reason they decided to have one of their tags written as "wind-speed". now to access the wind speed values that are embedded within the tag i have to create an array called wind-speed. its not like i want to put the dash in, its just because the array has to be the same name as the tag "wind-speed". and since someone else wrote that tag i cant change it!!
do you understand now?
I gave an example of the xml in my first post
Showing me XML is NOT showing me code. Code means PHP when you are on this site. XML is just a fanciful text file.
Just because data in an XML files has a dash does not mean that you need to make a PHP variable representation that is identical. The variable name that you use to name an array need not have anything to do with the name of the data that it represents and in many cases it doesn't.
So that having been said, have you written any PHP at all that access this XML?
BTW - There is no need to be rude. So if you don't want to be respectful and respond appropriately DON'T ASK ANY QUESTIONS.
The user docs on PHP.net have this note. Does this help?
Sometimes tag names do not respect PHP variable name syntax. For example I have a file like this:
<livre>
<�ditorial>
<�dition-originale ref="123">
bla bla bla
</�dition-originale>
</�ditorial>
</livre>
It's a perfectly valid XML file, but
$livre->�ditorial[0]->�dition-originale[0]->attributes()
will not work because of the hyphen.
The only solution I found is to write:
$livre->�ditorial[0]->{"�dition-originale"}[0]->attributes()
ok i put in the curly brackets like you suggested and its giving me this error for the line with the curly brackets:
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference
any ideas?