XML Efficiency

Results 1 to 2 of 2

Thread: XML Efficiency

  1. #1
    Join Date
    Dec 1969

    Default XML Efficiency

    Hi,<BR><BR>I have a custom control that I&#039;ve written in C# which reads an XML file and then generates some HTML content based on that XML file.<BR><BR>My question has to do with the efficiency of how I read the XML file. I have one very complex statement, and for this I&#039;m running an XPath expression and placing the results in an XPathNodeIterator.<BR><BR>This works well for that one complex statement, but there are other instances, where I simply want to select one tag of a particular name.<BR><BR>At the moment, I&#039;m doing this:<BR><BR>XPathNavigator clone = m_niOptionList.Current.Clone();<BR>XPathNodeIterat or ni;<BR><BR>string myString = "";<BR>ni = clone.Select("whatever");<BR>if (ni.MoveNext())<BR>&nbsp;&nbsp;&nbsp;myString = ni.Current.Value;<BR><BR>string anotherStr = "";<BR>ni = clone.Select("thenextthing");<BR>if (ni.MoveNext())<BR>&nbsp;&nbsp;&bsp;anotherStr = ni.Current.Value;<BR><BR>and so on...<BR><BR>I can&#039;t help but feel like this is a bit inefficient. However, I do like that fact that I am directly selecting the tag name. What annoys me about the XmlTextReader is that through the use of methods like MoveToElement or MoveToNextAttribute, I am not forcing my XML document to have any particular tag name. I suppose I could create an XMLSchema and use the XMLValidatingReader, but then I would end up using both an XPathNavigator and an XMLValidatingReader which is something I was trying to avoid.<BR><BR>Can anyone offer any advice as to what would be the most efficient to do what I&#039;m trying to do? Or what is the generally accepted started as far as reading XML files?<BR><BR>Thanks in advance.<BR>-Steve<BR>

  2. #2

    Default RE: XML Efficiency

    Speed and efficieny are not really reasons to XML.<BR><BR>If you have a small amount of data use a dom document instead of the reader/navigator combo.<BR><BR>To solve the speed and efficiency, cache the HTML output ;)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts