In-Line XML Editor: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
m (Ovidiu moved page MutableXMLDocument to In-Line XML Editor without leaving a redirect)
No edit summary
Line 5: Line 5:
=Overview=
=Overview=


<tt>MutableXMLDocument</tt> is an API that applies in-line configuration modifications in XML files.
<tt>InLineXMLEditor</tt> is an API that applies in-line configuration modifications in XML files.


A typical usage pattern is the following:
A typical usage pattern is the following:
Line 11: Line 11:
<pre>
<pre>
File file = ...;
File file = ...;
MutableXMLDocument d = new MutableXMLDocument(file);
InLineXMLEditor editor = new InLineXMLEditor(file);


boolean changeOccurred = d.set("/path/in/document", "value");
boolean changeOccurred = editor.set("/path/in/document", "value");


if (changeOccurred) {
if (changeOccurred) {


     d.write();
     editor.write();
}
}
else {
else {

Revision as of 05:25, 11 November 2016

Internal

Overview

InLineXMLEditor is an API that applies in-line configuration modifications in XML files.

A typical usage pattern is the following:

File file = ...;
InLineXMLEditor editor = new InLineXMLEditor(file);

boolean changeOccurred = editor.set("/path/in/document", "value");

if (changeOccurred) {

    editor.write();
}
else {

  //
  // the value we're trying to set is identical with the value present in the file, react accordingly 
  //
  
}

The modification preserves the original format, nothing is modified except the value that is being changed.