Hey all, I've run into a snag trying to use some XML output from NOAA.
The problem is that some of the fields it sends to me have a hyphen in
the name. Simple XML then creates objects with hyphens in their name.
So here's the object I am having issues with:
object(SimpleXMLElement)#7 (2) {
wind-speed => object(SimpleXMLElement)#9 (2) {
name => string(10) Wind Speed
value => array(37) {
0 => string(1) 4
1 => string(1) 4
2 => string(1) 6
3 => string(1) 4
4 => string(1) 4
5 => string(1) 4
6 => string(1) 2
7 => string(1) 0
8 => string(1) 2
9 => string(1) 8
10 => string(1) 8
11 => string(1) 8
12 => string(1) 8
13 => string(1) 8
14 => string(1) 8
15 => string(1) 8
16 => string(1) 8
17 => string(1) 6
18 => string(1) 4
19 => string(1) 6
20 => string(1) 6
21 => string(1) 8
22 => string(2) 14
23 => string(2) 12
24 => string(2) 12
25 => string(1) 8
26 => string(1) 8
27 => string(2) 10
28 => string(2) 10
29 => string(1) 8
30 => string(2) 10
31 => string(2) 10
32 => string(2) 10
33 => string(1) 8
34 => string(1) 6
35 => string(1) 8
36 => string(2) 10
}
}
direction => object(SimpleXMLElement)#10 (2) {
name => string(14) Wind Direction
value => array(37) {
0 => string(3) 240
1 => string(3) 230
2 => string(3) 220
3 => string(3) 216
4 => string(3) 210
5 => string(3) 220
6 => string(3) 230
7 => string(3) 230
8 => string(3) 218
9 => string(3) 202
10 => string(3) 160
11 => string(3) 164
12 => string(3) 168
13 => string(3) 180
14 => string(3) 190
15 => string(3) 180
16 => string(3) 170
17 => string(3) 100
18 => string(2) 30
19 => string(3) 340
20 => string(3) 288
21 => string(3) 282
22 => string(3) 330
23 => string(3) 310
24 => string(3) 314
25 => string(3) 280
26 => string(3) 286
27 => string(3) 294
28 => string(3) 296
29 => string(3) 298
30 => string(3) 306
31 => string(3) 316
32 => string(3) 316
33 => string(3) 328
34 => string(3) 338
35 => string(3) 350
36 => string(3) 350
}
}
}
And here's my code issues:
$xmlobj->data->parameters->direction access works fine.
$xmlobj->data->parameters->direction->value works fine. Gives me the array.
$xmlobj->data->parameters->wind-speed returns an int value of 0.
$xmlobj->data->parameters->wind-speed->value gives me an error:
Parse error: parse error, unexpected T_OBJECT_OPERATOR in noaa.php on
line 59
So, what am I doing wrong? The only thing I can think of is the - in the
wind-speed object name.
Any help would be appreciated!
-Charlie
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php