title: Small modification to an XML document using StAX
body: <p>I'm currently trying to read in an XML file, make some minor changes (alter the value of some attributes), and write it back out again.</p>
  
  <p>I have intended to use a StAX parser (<code>javax.xml.stream.XMLStreamReader</code>) to read in each event, see if it was one I wanted to change, and then pass it straight on to the StAX writer (<code>javax.xml.stream.XMLStreamReader</code>) if no changes were required.</p>
  
  <p>Unfortunately, that doesn't look to be so simple - The writer has no way to take an event type and a parser object, only methods like <code>writeAttribute</code> and <code>writeStartElement</code>. Obviously I could write a big switch statement with a case for every possible type of element which can occur in an XML document, and just write it back out again, but it seems like a lot of trouble for something which seems like it should be simple.</p>
  
  <p>Is there something I'm missing that makes it easy to write out a very similar XML document to the one you read in with StAX?</p>