Displaying empty result when trying to retrieve specific element attributes from xml in java using appium + selenium


I’m facing an issue in retrieving an specific element attribute xml from the provided xml.

In the login page I want the xml of only username and password fields. But the login page contains username, password, sign in button, remember me radio button, forgot password link

I’m able to retrieve the login page xml using “driver.getPageSource();”. Base on this xml I’m trying to to get the username and password field xml

DocumentBuilderFactory xmlFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = xmlFactory.newDocumentBuilder();
Document xmlDoc = docBuilder.parse("/Users/c5247941/Desktop/Login.xml");
XPathFactory xpathFact = XPathFactory.newInstance();
XPath xpath = xpathFact.newXPath();

	try(  PrintWriter out = new PrintWriter("/Users/test/Desktop/testing.xml" )  ){
              out.println( text123 );
	catch (Exception e) {
	XPathExpression expr = xpath.compile("/AppiumAUT/UIAApplication/UIAWindow[1]/UIAScrollView/UIATextField[@value and string-length(@value)!=0]");
	NodeList nl = (NodeList) expr.evaluate(xmlDoc, XPathConstants.NODESET);

	for (int i = 0; i < nl.getLength(); i++)
		Element el = (Element) nl.item(i);
		System.out.println("Second output"+el.getTextContent().toString());
		try(  PrintWriter out = new PrintWriter( "/Users/test/Desktop/Testcreate.xml" )  ){
			  out.println( el );
			catch (Exception e) {

Second output(with three lines of empty space) like

[TestNG] Running:

Second output

PASSED: tests
PASSED: launchPad

Thanks in advance