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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:54:22+00:00 2026-05-29T23:54:22+00:00

Using com.sun.org.apache.xml.internal.serialize.XMLSerializer and com.sun.org.apache.xml.internal.serialize.OutputFormat causes some errors when compiling using java 1.6. The solution

  • 0

Using com.sun.org.apache.xml.internal.serialize.XMLSerializer and com.sun.org.apache.xml.internal.serialize.OutputFormat causes some errors when compiling using java 1.6.
The solution I found is by using org.apache.xml.serialize.XMLSerializer and org.apache.xml.serialize.OutputFormat after adding xerces.
The problem is that theses classes are deprecated. What can I use without to replace them without touching the code ?
Thnx
This is the dependency I used :

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.9.1</version>
</dependency>
  • 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-29T23:54:23+00:00Added an answer on May 29, 2026 at 11:54 pm

    We can use the LSSerializer class from the package org.w3c.dom.ls

    public String toXML(Node source) {
    
        String subscrXML=null;
        StringWriter stringWriter=new StringWriter();
         try {
            //Get the implementations
    
            DOMImplementationRegistry registry =  DOMImplementationRegistry.newInstance();
    
            DOMImplementationLS impls =  (DOMImplementationLS)registry.getDOMImplementation("LS");
    
    
            //Prepare the output
            LSOutput domOutput = impls.createLSOutput();
            domOutput.setEncoding(java.nio.charset.Charset.defaultCharset().name());            
            domOutput.setCharacterStream(stringWriter);
            domOutput.setEncoding(ENCODING);
            //Prepare the serializer
            LSSerializer domWriter = impls.createLSSerializer();            
            DOMConfiguration domConfig = domWriter.getDomConfig();
            domConfig.setParameter("format-pretty-print", true);
            domConfig.setParameter("element-content-whitespace", true);
            domWriter.setNewLine("\r\n");     
            domConfig.setParameter("cdata-sections", Boolean.TRUE);
            //And finaly, write
            domWriter.write(source, domOutput);
            subscrXML = domOutput.getCharacterStream().toString();
            DOMStringList dsl=domConfig.getParameterNames();
            System.out.println(subscrXML);
            /*
             // Just for curiosity.... 
             for(int i=0;i<dsl.getLength();i){
                System.out.println(dsl.item(i)" = ["domConfig.getParameter(dsl.item(i))"]");
            }*/
         } catch (Exception e) {
             e.printStackTrace();
         }
        return subscrXML;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using com.sun.org.apache.xpath.internal.XPathAPI for some time and it seems to work ok.
Dear forum, what is the difference between the JDK contained import com.sun.org.apache.xml.internal.resolver.CatalogManager; and the
I am using http://java.sun.com/jsp/jstl/fmt tag library for outputting messages from Message Resource Bundle which
I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using
My web.xml is: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd id=WebApp_ID version=2.5> TestStruts2 <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name>
Parsing an XML file using the Java DOM parser results in: [Fatal Error] os__flag_8c.xml:103:135:
I have 2 strings, an XML string I constructed using Java DOM interface, and
I have project A which a pom.xml dependency of: <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-email</artifactId> <version>1.2</version> </dependency>
When using COM boolean values are to be passed as VARIANT_BOOL which is declared
Without : MFC ATL using COM , with pure C++ , steps taken thus

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.