can not install XML package

It seems you are right. I did not see that at first. It seems the R installation is using the python libxml2 installation. It may not be the same. You should check that.

You may be able to use environment variable to precise the path to your libxml library to change the one change by pkg-config

There are also other environment variables that could be used to configure the compilation.
like XML/configure at 1200e8d2e2cd4910537b700245c9d58350c3e351 · omegahat/XML · GitHub

I did not find a lot of documentation for changing the default.

I guess you can also change you pkgconfig configuration so that the python one is not found by default.

For xml2, the configuration can use --configure-vars installation option, to precise INCLUDE_DIR and LIB_DIR (see configure too)

Hope you'll find how to do this. I think you are on the right track.