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 7128663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:09:43+00:00 2026-05-28T11:09:43+00:00

please help me to parse the xml with attributes from the given xml.. <tarifs>

  • 0

please help me to parse the xml with attributes from the given xml..

 <tarifs>
<tarif type="internet" name="ОнЛайм 4" price="300" speedin="4" speedout="2"/>
<tarif type="internet" name="ОнЛайм 10" price="400" speedin="10" speedout="5"/>
<tarif type="internet" name="ОнЛайм 20" price="500" speedin="20" speedout="10"/>
</tarifs>

I have treid this

NodeList node = element.getElementsByTagName("tarif");
for (int j = 0; j < node.getLength(); j++) {                        
    initialValues.put(TRAILER_ID, j);                   
    initialValues.put(TRAILER_TITLE, node.item(j).ATTRIBUTE_NODE.getNamedItem("name").nodeValue);
}

But its not working for me.. PLease anyone help me to solve this

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-05-28T11:09:43+00:00Added an answer on May 28, 2026 at 11:09 am

    Try this :

    public void vParseXMLList(String sXMLResult)
        {
            org.xml.sax.helpers.DefaultHandler handler = new DefaultHandler() 
            {
                boolean bIsMachineNameFound = false;
                boolean bIsMachineSizeFound = false;
                boolean bIsCreateDateFound = false;
                boolean bIsMachineGUIDFound = false;
                boolean bIsTimelinePasswordFound = false;
                boolean bSHAPassword = false;
                boolean bGUIDPassword = false;
    
                public void startElement(String uri, String localName,String qName, Attributes attributes) throws SAXException 
                {
                    if (localName.equalsIgnoreCase("tarif")) {
                        if(attributes.getValue("type") != null){
                            String sType = attributes.getValue("type"); 
                        }
    
                        if(attributes.getValue("name") != null){
                            String sName = attributes.getValue("name"); 
                        }
    
                        if(attributes.getValue("price") != null){
                            int nPrice = Integer.parseInt(attributes.getValue("price")); 
                        }
    
                        if(attributes.getValue("speedout") != null){
                            int nSpeedOut = Integer.parseInt(attributes.getValue("speedout")); 
                        }
    
                        if(attributes.getValue("speedin") != null){
                            int nSpeedIn = Integer.parseInt(attributes.getValue("speedin")); 
                        }
                    }
                }
    
                public void endElement(String uri, String localName, String qName)
                        throws SAXException {           
                }
    
                public void characters(char ch[], int start, int length) throws SAXException 
                {
                }
            };
            SAXParserFactory saxParserFactory;
            SAXParser saxParser;
            InputStream inputStream;
    
            try {
                    saxParserFactory = SAXParserFactory.newInstance();
                    saxParser = saxParserFactory.newSAXParser();
                    inputStream = new ByteArrayInputStream(sXMLResult.getBytes("UTF-8"));
                    saxParser.parse(inputStream, handler);
    
            } 
            catch (UnsupportedEncodingException e) {} 
            catch (ParserConfigurationException e) {} 
            catch (SAXException e) {} 
            catch (IOException e) {}
            finally
            {
                saxParserFactory = null;
                saxParser = null;
                inputStream = null;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me to parse xml from another xml... i have this xml named
<input src=LOGO.JPG type=image name=imagem> I have an xml element that contains the image path
Please help me parse a configuration file of the below prototype using lxml etree.
I'm trying to parse the xml document returned from this link but I get
Please anybody help me.i am in great trouble....Now my Problem is... Using xml parser
From my observations overall JSON is faster to Parse than XML . I have
I am getting this error while trying to Parse the Xml response from the
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Please help! I'm really at my wits' end. My program is a little personal
Please help! Background info I have a WPF application which accesses a SQL Server

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.