Obtaining consent for HIV testing in children involves both the healthcare provider and the parents or guardians. Informed consent is necessary before conducting the test, ensuring that parents understand the need, benefits, and potential outcomes of the test.