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

  • SEARCH
  • Home
  • 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 8435941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:03:35+00:00 2026-06-10T07:03:35+00:00

I have one XML which look like this :: <Channels> <Channel Id=511 Title=Test ChannelDescription=This

  • 0

I have one XML which look like this ::

<Channels>
       <Channel Id="511" Title="Test" ChannelDescription="This is Test Channel./>
</Channels>

I am successfully parse this kind of XML.My Problem is that when i fired the webservice and if there is no authentication from the server then the webservice response like this::

<AuthenticationError>An Active Session Already Exists For This User.</AuthenticationError>

So how can i check that root node is “Authentication Error” or “Notes”. And if i get the Authentication Error tag then how can i get its node value which is “An Active Session Already Exists For This User.”??

Code for XML Parsing is this::

NodeList node =null;
node= (NodeList)result.getElementsByTagName("Channels");


for(int j=0;j<node.getLength();j++)
{                             
Node aNode=node.item(j);  
Element fstElmnt = (Element) aNode;

NodeList websiteList = fstElmnt.getElementsByTagName("Channel");
int check=websiteList.getLength();

for(int k=0;k<check;k++)
{
    DatabaseConstant myChannels = new DatabaseConstant();
    Node checkNode=websiteList.item(k);

    Element websiteElement = (Element) checkNode;                                                                               
    myChannels.id=websiteElement.getAttribute("Id");
    myChannels.title=websiteElement.getAttribute("Title");

    channel .add(myChannels);
    }
}
}

I hope my question is clear… Please provide the solution asap. Thanks in Advance….

  • 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-10T07:03:36+00:00Added an answer on June 10, 2026 at 7:03 am

    Use getDocumentElement() to get root Element, then use getTagName() to get tag name.

    Example:

        Element root = result.getDocumentElement();
        String name = root.getTagName();
    
        if(name.equalsIgnoreCase("AuthenticationError") )
        {
            String value = myDocument.getDocumentElement().getTextContent();
            System.out.println("Error:" + value);
        }
        else if(name.equalsIgnoreCase("Notes") )
        {
           NodeList nodes = root.getElementsByTagName("Channels");
    
           for(int i = 0 ; i < nodes.getLength() ; i ++)
           {
               //-----do something with channels nodes--
           }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have One XML file which will be look like this :: <Note> <NoteId>13328</NoteId>
I have an XML file which has many section like the one below: <Operations>
I have a sample xml file which looks like the one below: <Root> <SubOne>
I have an XML which might be like one of the following: // #1
I have one XML request which I need to modify (to XML) and then
I am having on xml from which i have to remove the one book
I have a GridView which is databound to an XML Datasource. For one of
i have one xml like, Declare @xmldata xml; set @xmldata =' <Customers> <Id>1</Id> <Name>foo</Name>
i have a table like this one: id | name | score mapped to
This is my Source-XML. It is originally a Word-ML which have been reduced to

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.