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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:59:48+00:00 2026-05-20T09:59:48+00:00

i have this xml: <user> <name>H &amp; M</name> and i parse it using this

  • 0

i have this xml:
<user>
<name>H &amp; M</name>

and i parse it using this code:


    DocumentBuilder documentBuilder = null;
            Document document = null;

try { documentBuilder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); document = documentBuilder.parse(is); } catch (Exception e) { return result; } NodeList nl = document.getElementsByTagName(XML_RESPONSE_ROOT); if (nl.getLength() > 0) { resp_code = nl.item(0).getAttributes().getNamedItem( XML_RESPONSE_STATUS).getNodeValue(); if (resp_code.equals(RESP_CODE_OK_SINGLE)) { nl = document .getElementsByTagName(XML_RESPONSE_TAG_CONTACT); NodeList values = nl.item(i).getChildNodes();

etc..

when i get the node value by: node.getNodeValue();

i get only what’s before the ampersand, even though the ampersand is escaped

i want to get the whole string: “H & M”

thanks

  • 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-20T09:59:49+00:00Added an answer on May 20, 2026 at 9:59 am

    It depends on how your XML document was constructed. In particular, it can have multiple adjucent Text nodes in “H & M” while your code expects it to be just one. Try to use nodeVariable.normalize() before getting its value.

    According to DOM parser API: “normalize() – Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a “normal” form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes…”

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

Sidebar

Related Questions

I have this page: http://www.ryancoughlin.com/files/xml/ - if you select User -> Someones name You
I have this code: ... request data = new request(); data.username = formNick; xml
I have this XML in a column in my table: <keywords> <keyword name=First Name
please help me to parse xml from another xml... i have this xml named
I have this xml data format. I would like to extract the properties name
I have this XML : <?xml version=1.0 encoding=utf-8 ?> <IMPORT mode=FULL> .... </IMPORT> I'm
I have this XML: <?xml version=1.0 encoding=utf-8?> <ConfiguraCanale ID_Comando=1> <canaleDigitalOUTPUT ID_Canale=1 > <stato>0</stato> </canaleDigitalOUTPUT>
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
For example i have this xml. I need to get value of parameter val

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.