Instead of text.value(), you should use either text.child_value() or text.text().get().
child_value("a") is equivalent to child("a").child_value(), not child("a").value(). The reason is that text is located in special PCDATA nodes - child_value() usually is the same as first_child().value().