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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:52:47+00:00 2026-05-15T07:52:47+00:00

for eg. root= <root> <param value=abc> <param value=bc> </root> NodeToInsert could be <insert><parameterDesc>afds</parameterDesc></insert> The

  • 0

for eg. root=

<root>
  <param value="abc">
  <param value="bc">
</root>

NodeToInsert could be

<insert><parameterDesc>afds</parameterDesc></insert>

The output should be:

<root>
  <insert><parameterDesc>afds</parameterDesc></insert>
  <param value="abc">
  <param value="bc">
</root>  
  • 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-15T07:52:47+00:00Added an answer on May 15, 2026 at 7:52 am

    I’ll be really irritated if it turns out I just did your homework for you.

    package com.akonizo.examples;
    
    import java.io.ByteArrayInputStream;
    import java.io.StringWriter;
    
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.Text;
    
    public class XmlInsertExample {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            String initial = "<root><param value=\"abc\"/><param value=\"bc\"/></root>";
    
            try {
                // Parse the initial document
                ByteArrayInputStream is = new ByteArrayInputStream(initial.getBytes());
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                Document doc = db.parse(is);
    
                // Create the new xml fragment
                Text a = doc.createTextNode("afds");
                Node p = doc.createElement("parameterDesc");
                p.appendChild(a);
                Node i = doc.createElement("insert");
                i.appendChild(p);
                Element r = doc.getDocumentElement();
                r.insertBefore(i, r.getFirstChild());
                r.normalize();
    
                // Format the xml for output
                Transformer transformer = TransformerFactory.newInstance().newTransformer();
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    
                // initialize StreamResult with File object to save to file
                StreamResult result = new StreamResult(new StringWriter());
                DOMSource source = new DOMSource(doc);
                transformer.transform(source, result);
    
                System.out.println(result.getWriter().toString());
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    The result will be:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <root>
      <insert>
        <parameterDesc>afds</parameterDesc>
      </insert>
      <param value="abc"/>
      <param value="bc"/>
    </root>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Look this xsl template: <xsl:template match=root> <xsl:param name=bla select=/.. /> <ha> <xsl:value-of select=$bla />
web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>
I need to generate XML in the following form: <ns1:root xmlns:ns1=http://example.com/xmlns1 xmlns:ns2=http://example.com/xmlns2> <ns2:item ns2:param=value
[root@LINUX misc]# pwd /usr/local/openssl/ssl/misc [root@LINUX misc]# ./tsget -h http://tsa.opentsa.org:8080/tsa ../../bin/alllog.log.tsq ../../bin/alllog.log.tsq: fatal error: could
Root view is a UIImage View, it has subviews, those have subviews. My root
root@everton-laptop:/opt/tinyos-1.x/apps/Blink# make pc compiling Blink to a pc binary ncc -o build/pc/main.exe -g -O0
[root@234571-app2 git]# ./test.py File ./test.py, line 4 with open(/home/git/post-receive-email.log,'a') as log_file: ^ SyntaxError: invalid
The root of the problem for me is that Java does not allow references.
map.root :controller => main, :action => index is not redirecting the main controller to
The root of my question is that the C# compiler is too smart. It

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.