I have two XML files from which I can get the data but from the other I cannot.
have you checked the namespace of the xmls?
they have different namespace
So if you have used namespaces for getting your xml elements in one then the same will not work for other namespace elements of the other xml as they become unique.
If they are completely 2 different xmls but similar elements then you can check and process each separately or you can check and make the ns dynamic