<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist SYSTEM "http://www.apple.com/DTDs/PropertyList-1.0.dtd" PUBLIC "-//Apple//DTD PLIST 1.0//EN">

-<plist version="1.0">










Above one is the XML file. I need to get the value for the Google analytics from the above xml file

I need to get the output as Type: Prod, Key: GA, Value: UA-111111-24 from the above XML. I have tried the following code but it's not showing any output.

NodeList dictList = document.getElementsByTagName("dict");
for (int j = 0; j < dictList.getLength(); j++) {
    if (dictList.item(j) instanceof Element) {
        Element dict = (Element) dictList.item(j);

        NodeList nodeList = dict.getElementsByTagName("key");
        NodeList nodeList1 = dict.getElementsByTagName("string");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);

            if (node.getTextContent().equals("GAAnalyticsKey")) {
                Node node1 = nodeList1.item(i);
                System.out.println("Nodename" + node.getNodeName() + " : "
                        + node.getTextContent().trim() + " " + node1.getNodeName() + " : "
                        + node1.getTextContent().trim());

Can you help me on this ? I'm not getting the proper values after implementing your code. For ex if (node.getTextContent().equals("GAAnalytics")) I'm getting some other value

closed as off-topic by IAmMilinPatel, Niels van Reijmersdal, alecxe Sep 22 '17 at 11:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development unrelated to testing are off-topic here, but can be asked on Stack Overflow." – IAmMilinPatel, Niels van Reijmersdal, alecxe
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.