<?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

Browse other questions tagged or ask your own question.