XML (.NET 1.1) Performance Checklist

From Guidance Share

Jump to: navigation, search

J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman

Contents

Design Considerations

  • Choose the appropriate XML class for the job.
  • Consider validating large documents.
  • Process large documents in chunks, if possible.
  • Use streaming interfaces.
  • Consider hard-coded transformations.
  • Consider element and attribute name lengths.
  • Consider sharing the XmlNameTable.


Parsing XML

  • Use XmlTextReader to parse large XML documents.
  • Use XmlValidatingReader for validation.
  • Consider combining XmlReader and XmlDocument.
  • On the XmlReader, use the MoveToContent and Skip methods to skip unwanted items.


Validating XML

  • Use XmlValidatingReader.
  • Do not validate the same document more than once.
  • Consider caching the schema.


Writing XML

  • Use XmlTextWriter.


XPath Queries

  • Use XPathDocument to process XPath statements.
  • Avoid the // operator by reducing the search scope.
  • Compile both dynamic and static XPath expressions.


XSLT Processing

  • Use XPathDocument for faster XSLT transformations.
  • Consider caching compiled style sheets.
  • Consider splitting complex transformations into several stages.
  • Minimize the size of the output document.
  • Write efficient XSLT.


Resources

Personal tools