How to read two analog inputs from the XBee Series 2?

I would like to know how I can control the data from two analog in put in my XBee Series 2. I have a sensor that sends data using a LDR (AD0) and a LM35(AD2) temperature sensor. I do not know how can I get the correct analog samples from the LM35. The LDR data seems to be correctly but the second two bytes that belong to LM35 data are read wrong.

I think that when the XBee sends the I/O data frames (with two analog inputs) it sends first the two bytes from AD0 and then the two bytes from AD2. Should I control other bytes like analog channel mask?

Here I copy the wrong piece of code:

void loop()
// In API mode, the frame type is I/O data sample.So, if we have everything in the buffer
if (Serial.available() >= 23) {
// Looking the starter byte (0x7E)
if ( == 0x7E) {
//blink debugLED when data is received
digitalWrite(debugLED, HIGH);
digitalWrite(debugLED, LOW);
//We have already read the start byte and then we discard bytes we are not using (20 data bytes are discard).
//We want to read only analog data from the sensor.
for (int i = 0; i<20; i++) {
byte discard =;
// Copy analog samples
int analogHigh =; // data from LDR
int analogLow =; // data from LDR
int analogHighT =; // data from LM 35
int analogLowT =; // data from LM 35
analogValue = analogLow + (analogHigh256);
analogValueT = analogLowT + (analogHighT
miliV = (analogValueT*1200)/1024.0;
celsius = miliV/res;

Thank you in advance