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 inputs 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 a piece of code:

int analogValue = 0; //store data from LDR
int analogValueT = 0; //store data from LM35
float miliV = 0.0; //milivolts from LM35
int res = 10; // 10mV/C
float celsius = 0.0;

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 (Serial.read() == 0x7E) {
//blink debugLED when data is received
digitalWrite(debugLED, HIGH);
delay(10);
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 = Serial.read();
}
// Copy analog samples
int analogHigh = Serial.read(); // data from LDR
int analogLow = Serial.read(); // data from LDR
int analogHighT = Serial.read(); // data from LM 35
int analogLowT = Serial.read(); // data from LM 35

analogValue = analogLow + (analogHigh256);
analogValueT = analogLowT + (analogHighT
256);
miliV = (analogValueT*1200)/1024.0;
celsius = miliV/res;
}
}

Thank you in advance

I would like to know how I can control the data from two analog inputs in my XBee Series 2.

The XBee can't "control" the data. It can read the data. It can send the data. It has NO control over the data.

I have a sensor that sends data using a LDR (AD0) and a LM35(AD2) temperature sensor.

No, you don't. You might have an Arduino with XBee attached that gets data from those sensors. You might have dispensed with the Arduino, and just have the sensors connected to the XBee.

I do not know how can I get the correct analog samples from the LM35.

That code doesn't read anything from an LM35. That code reads data from the serial port, where, presumably, an XBee is putting the data.

You need to tells us what the configuration of the sending XBee is.

// In API mode, the frame type is I/O data sample.So, if we have  everything in the buffer

Have you confirmed this? Have you written code which simply reads and prints every byte received?

//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 = Serial.read();
      }

You've made sure that there are 23 bytes in the buffer. You've made sure that the first one is the start of packet marker. Now, without even printing these, you are just going to throw away 20 bytes. That's a total of 21 of the 23 dealt with (correctly or not). That leaves 2 bytes to be dealt with.

      // Copy analog samples
      int analogHigh = Serial.read(); // data from LDR
      int analogLow = Serial.read(); // data from LDR
      int analogHighT = Serial.read(); // data from LM 35
      int analogLowT = Serial.read(); // data from LM 35

So, you now read all 4 of the 2 bytes available. And, you wonder why you don't get any data from the LM35?

Thank you PaulS for your time.
I'm starting with Arduino and XBee modules. I'll try to do it again with your advices and ask again if there is any problem.