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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:34:34+00:00 2026-06-13T12:34:34+00:00

I convert org.w3c.dom.Element to String in this way: StringWriter writer = new StringWriter(); Transformer

  • 0

I convert org.w3c.dom.Element to String in this way:

StringWriter writer = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.transform(new DOMSource(node), new StreamResult(writer));
String result = writer.toString();

But when I use it later I get an exception: io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence which says about wrong encoding.

  • 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-13T12:34:35+00:00Added an answer on June 13, 2026 at 12:34 pm

    In fact, it’s completely unnecessery. I needed it for serialization nodes and further export them to different formats (xml, html, test). So I found out that it’s better to share org.w3c.dom Documents. From Document you can get any information you need.

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

Sidebar

Related Questions

Is it possible to convert nu.XOM.Element to org.w3c.dom.Element ? Am trying to construct XML
When I am parsing the string to org.w3c.dom.Element I am getting following exception. org.xml.sax.SAXParseException;
I want to convert a org.w3c.dom.Document object to a String. I'm using Java 6
I'm looking for a way to convert text like this: <!DOCTYPE html PUBLIC \-//W3C//DTD
I have a XML org.w3c.dom.Document object. It looks sorta like this: <A> <B> <C/>
Is it possible to convert webdriver/selenium's org.openqa.selenium.webelement to org.w3c.dom.domelement ?
Is this the right way to convert a string to a list? List styles
Is there anyway to convert an instance of org.w3c.dom.Document to org.apache.html.dom.HTMLDocumentImpl. I need to
Title is pretty self-explanatory. How can I convert an instance of org.w3c.dom.Document to a
I am doing a lot of XML parsing/transformation using the org.w3c.dom classes. A Document

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.