How to add a node to text node in Java? I want to do this on a xml document
From:
<doc> My Long text </doc>
To:
<doc> My <b>Long</b> text </doc>
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Assuming that you’ve parsed the XML and have a DOM. What you need to do is:
Delete the existing text node from the
<doc>element.Insert the a text node consisting of the first part of the text into the
<doc>element.Insert an element node for the
<b>element into the<doc>element.Insert the text content into the
<b>element.Insert the a text node consisting of the remainder of the text into the
<doc>element.