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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:59:25+00:00 2026-05-23T08:59:25+00:00

Using: javax.xml and org.w3c : public void removeNodeFromXML(File xmlfile_, String uuid) { DocumentBuilderFactory factory

  • 0

Using: javax.xml and org.w3c:

public void removeNodeFromXML(File xmlfile_, String uuid)
  {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(xmlfile_);

    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer tFormer = tFactory.newTransformer();

   //????

   Element rootElement = doc.getRootElement();
   rootElement.removeChild("1236");

   //???

   // Normalize the DOM tree to combine all adjacent nodes
   doc.normalize();
   Source source = new DOMSource(doc);
   Result dest = new StreamResult(xmlfile_);
   tFormer.transform(source, dest);

  }

XML looks like this

<Servers>
 //remove this guy
 <server ID="1236">
  <name>Josh</name>
  <port>1234</port>
  <ip>12.2.2.3</ip>
 </server>

<server ID="1237">
  <name>John</name>
  <port>1234</port>
  <ip>12.2.2.3</ip>
 </server>
</Servers>
  • 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-23T08:59:26+00:00Added an answer on May 23, 2026 at 8:59 am

    You can use XPath to select specific elements/attributes. Just search the web for Tutorials. Here is good one. You should also read the Java-Doc for java.xml.xpath, which includes short examples.

    The XPath-Expression for your XML-File is: /server[@ID='xxxx']

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

Sidebar

Related Questions

I'm using the javax.xml.transform.Transformer class to perform some XSLT translations, like so: TransformerFactory factory
I am parsing a XML file in Java using the W3C DOM. I am
I'm using Java 1.6. Given a org.w3c.dom.Node object, how do I get a String
I'm working with SOAP using the javax.xml.soap package. I have a javax.xml.soap.SOAPMessage object that
I am using Java back end for creating an XML string which is passed
I have to write an XML file using java.The contents should be written from
I'm using java.text.SimpleDateFormat to parse string representations of date/time values inside an XML document.
I am generating the xml file using the DOM and the program is working
I am using the following code to validate an an XML file against a
I have to turn a org.w3c.dom.Document into a java.lang.String. I have found two possible

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.