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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:16:22+00:00 2026-06-18T07:16:22+00:00

I am using Org.W3c.dom for generating and parsing XML files in my app. Here

  • 0

I am using Org.W3c.dom for generating and parsing XML files in my app.

Here I am stuck because I can not find a way to add more elements to a Root element.

I want to generate Xml as below :

<root>
       <siteDesc>abc</siteDesc>
       <respCode>false</respCode>
       <respMsg>Done</respMsg>
  </root>

Here is the code which I am using to generate XML File …

private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
Element responseElement = document.createElementNS(NAMESPACE_URI, "root");
responseElement.appendChild("TODO") // Confused Here .. How to append elements with their names

Can anyone suggest me, Here In above code .. What are the required changed to add elements to the roor node ????

  • 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-18T07:16:23+00:00Added an answer on June 18, 2026 at 7:16 am

    You want to

    1. create a node and add that to your document (responseElement)
    2. create further Elements and add those to your responseElement (again, using appendChild())
    3. for each of these, create a TextNode and add those to your Elements

    In the above, the element creation is distinct from the addition to the document.

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

Sidebar

Related Questions

I am using org.w3c.dom.Element for adding elements to a xml file. Problem here is
I can copy a node from one XML file to another using org.w3c.dom.Document. importNode(Node
I am doing a lot of XML parsing/transformation using the org.w3c.dom classes. A Document
i am using org.w3c.dom in java to read an xml with the following function
I am using rpxnow in Java, how do I use org.w3c.dom API to get
Is it possible to convert nu.XOM.Element to org.w3c.dom.Element ? Am trying to construct XML
I am using the following code for parsing of small xml files and it
Using: javax.xml and org.w3c : public void removeNodeFromXML(File xmlfile_, String uuid) { DocumentBuilderFactory factory
I'm using Java 1.6. Given a org.w3c.dom.Node object, how do I get a String
I want to convert a org.w3c.dom.Document object to a String. I'm using Java 6

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.