Given a xml file as input howto modify a attribute of a tag with a new string value?
Function is
updateXMLAttribute(Document doc , String tag, String attribute, String newValue){
//impl
}
How can i do it?
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.
I assume, by Document you mean org.w3c.dom.Document:
This will update all attribute values of attributes named in elements named in a dom document.
Of course, you should add appropriate error handling and null-checks.
PS: You can find all the information in the dom api documentation: http://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/Document.html