13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if (m_reader.HasAttributes){// Consider only the attribute changes <strong>for</strong> the givennodeDataView view = new DataView(m_tableOfChanges);view.RowFilter = "Node='"+ nodeName + "'";while(m_reader.MoveToNextAttribute()){// Beg<strong>in</strong> writ<strong>in</strong>g the attributem_writer.WriteStartAttribute(m_reader.Prefix,m_reader.LocalName, m_reader.NamespaceURI);// Search <strong>for</strong> a correspond<strong>in</strong>g entry// <strong>in</strong> the table of changesDataRow[] rows =m_tableOfChanges.Select("Attribute='"+m_reader.LocalName + "' AND OldValue='"+m_reader.Value + "'");if (rows.Length >0){DataRow row = rows[0];m_writer.WriteStr<strong>in</strong>g(row["NewValue"].ToStr<strong>in</strong>g());}elsem_writer.WriteStr<strong>in</strong>g(m_reader.Value);}}// Move back the <strong>in</strong>ternal po<strong>in</strong>term_reader.MoveToElement();}// Clear the table of changesm_tableOfChanges.Rows.Clear();m_tableOfChanges.AcceptChanges();The follow<strong>in</strong>g code, called by a client application, creates a copy of the sourcedocument and updates node attributes:void UpdateValues(str<strong>in</strong>g nodeName, str<strong>in</strong>g attribName,str<strong>in</strong>g oldVal, str<strong>in</strong>g newVal)156

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!