Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:31:51+00:00 2026-06-12T22:31:51+00:00

I have the following XML code: <CampaignFrameResponse xmlns=http://Qsurv/api xmlns:i=http://www.w3.org/2001/XMLSchema-instance> <Message>Success</Message> <Status>Success</Status> <FrameHeight>308</FrameHeight> <FrameUrl>http://delivery.usurv.com?Key=a5018c85-222a-4444-a0ca-b85c42f3757d&amp;ReturnUrl=http%3a%2f%2flocalhost%3a8080%2feveningstar%2fhome</FrameUrl> </CampaignFrameResponse>

  • 0

I have the following XML code:

<CampaignFrameResponse
  xmlns="http://Qsurv/api"
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Message>Success</Message>
  <Status>Success</Status>
  <FrameHeight>308</FrameHeight>   
  <FrameUrl>http://delivery.usurv.com?Key=a5018c85-222a-4444-a0ca-b85c42f3757d&amp;ReturnUrl=http%3a%2f%2flocalhost%3a8080%2feveningstar%2fhome</FrameUrl> 
</CampaignFrameResponse>

What I’m trying to do is extract the nodes and assign them to a variable. So for example, I’d have a variable called FrameHeight containing the value 308.

This is the Java code I have so far:

private void processNode(Node node) {
    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node currentNode = nodeList.item(i);
       if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
            //calls this method for all the children which is Element
            LOG.warning("current node name: " + currentNode.getNodeName());
            LOG.warning("current node type: " + currentNode.getNodeType());
            LOG.warning("current node value: " + currentNode.getNodeValue());
            processNode(currentNode);
       }
    }

}

This prints out the node names, types and values, but what is the best way of assigning each of the values to an appropriately-named variable? eg int FrameHeight = 308?

This is my updated code where the nodeValue variable keeps returning null:

processNode(Node node) {
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
    Node currentNode = nodeList.item(i);
    if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
        //calls this method for all the children which is Element
        String nodeName = currentNode.getNodeName();
        String nodeValue = currentNode.getNodeValue();
        if(nodeName.equals("Message")) {
            LOG.warning("nodeName: " + nodeName); 
            message = nodeValue;
            LOG.warning("Message: " + message); 
        } 
        else if(nodeName.equals("FrameHeight")) {
            LOG.warning("nodeName: " + nodeName); 
            frameHeight = nodeValue;
            LOG.warning("frameHeight: " + frameHeight);
        }
        processNode(currentNode);
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:31:52+00:00Added an answer on June 12, 2026 at 10:31 pm

    Xstream wont support in your case, it can be used for convert object to xml then get back again. If your xml is generated from an instance of CampaignFrameResponse class, u can use xstream.

    Otherwise you simply check like

    String nodeName = currentNode.getNodeName()
    String nodeValue = currentNode.getNodeValue() ;
    if( nodeName.equals("Message")){
         message = nodeValue ;
    } else if( nodeName.equals("FrameHeight") {
         frameHeight = nodeValue ;
    }
    

    You need to parse if you need int value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml code: <OML> <bg-def xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance name=EX1/> </OML> I want to
I have the following .xsd code: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema id=MyDataSet> <xs:element name=Row>
I have following xml structure <quiz xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=quiz.xsd> <mchoice> <question>What is the capital city
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
I have the following xml code: <soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/> <soapenv:Body> <cms:RelatedConfigurationItemList xmlns:cms=some namespace> <ConfigurationItem> <name>data</name>
I have the following XML code: <root> <options> <companies> <company url=http://www.brown.com>Brown LLC</company> <company url=http://www.yellow.com>Yellow
I have the following XML code for my cells (search_cell.xml) : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have the following code to read in an XML file: $xml2 = simplexml_load_file('http://www.facebook.com/feeds/page.php?format=rss20&id=334704593230758');
I have the following code: $page=3; $i=1; while($i<=$pages) { $urls .= '.http://twitter.com/favorites.xml?page= . $i
I have the following xml object representing a ImageButton <?xml version=1.0 encoding=utf-8?> <ImageButton xmlns:android=http://schemas.android.com/apk/res/android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.