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


-<dict>

<key>apiKeys</key>


-<dict>

<key>dev</key>


-<dict>

<key>DFPAdKeyMenu</key>

<string/>

    <key>DFPAdKeySport</key>
    <string>/182084332/UGAH_Banner_Dev</string>
    <key>DFPAdKeyFeed</key>
    <string>/182084332/UGAH_InFeed_Dev</string>
    <key>DFPAdKeyFeedInterstitial</key>
    <string>/182084332/UGAH_Interstitial_Dev</string>  
    <key>lemonSdkAppKey</key> 
    <string>d2f5979e-1797-4faa-af76-fbe329ee4261</string> 
    <key>lemonSdkPassword</key>
    <string>8b{S$7JpfL</string>
    <key>GAAnalyticsKey</key>
    <string>UA-101490859-24</string>

</dict>

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.