Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

XmlTextReader or DOM/XPath? Custom forward only parsing class?

Avatar of coltrane2003
coltrane2003 asked on
4 Comments1 Solution996 ViewsLast Modified:

My web app uses content parsed from XML files with an XmlTextReader.

I have read that the XmlTextReader employs a forward only pull method that is much less memory intensive than using the DOM.

I am not positive but I think that if my page class uses an XmlTextReader that the content from the reader is not cached. Instead this part of the page is rendered each time with my XmlTextReader code. This actually represents a substantial amount of code because I am storing a bunch of XHTML structural markup in my XML files along with meta data, workflow, etc.

At this point my app is starting to look like a big plate of spaghetti. I've got a bunch of counter variables, collections, and conditions. I don't have any formal OO training, but I am feeling like this would be a good time for me to write a class that parses my XML taken from the XmlTextReader. I'm also using this same logic in a number of places.

What I would really like to know is whether this makes any sense at all? Am I wasting my time doing this? If ASP.NET would serve cached pages until changes were made to the XML files, I could just use the DOM and life would be easier. On the other hand if this is not possible it seems like writing this custom class would be handy?

I have read that performance is improved by up to 5 times with forward only parsing. If this is the case, it seems like it would make sense to write a class to help with this logic? For example, I've noticed that the XmlTextReader counts both the opening and closing tags with the name property. So, I've written logic that keeps track with counter variables and checks to see if I've hit the closing tag with a statement like
if(subSwitchCount % 2 == 0)

This allows me to store the keywords below in a multidimensional array so the categories remain separate.

<item title="Home">
      <keyword>help seeking</keyword>
      <keyword>information seeking</keyword>
      <keyword>social networks</keyword>
      <keyword>community information</keyword>
      <keyword>information psychology</keyword>
      <keyword>information seeking contexts</keyword>
      <keyword>University of Washington</keyword>
      <keyword>University of Michigan</keyword>
      <keyword>Information School</keyword>
      <keyword>School of Information</keyword>
    <description>Information Behavior in Everyday Contexts (IBEC) - </description>
  <item title="About IBEC">
      <keyword>Contact information</keyword>
      <keyword>Funding organizations</keyword>
      <keyword>Best practice</keyword>
      <keyword>Information products</keyword>
      <keyword>Information delivery</keyword>
    <description>The following page contains detailed information about IBEC’s research efforts to maximize the impact of information in communities.</description>
  <item title="Projects">
      <keyword>Field studies</keyword>
      <keyword>United Way</keyword>
      <keyword>Community Programming</keyword>
      <keyword>Info grounds</keyword>
      <keyword>Health Information</keyword>
      <keyword>Tipping points</keyword>
      <keyword>After school</keyword>
    <description>At IBEC we conduct field studies of real people in real situations by partnering with government, corporate and nonprofit organizations.  Descriptions of current and past projects are provided through this page.</description>
  <item title="Publications">
    <description>Publications - </description>
  <item title="Tools and Resources">
      <keyword>IBEC database</keyword>
    <description>Several tools and resources developed and utilized by IBEC are presented on this page.</description>

In my amateur estimation this approach would sort of be like having DOM functionality a la carte.

Any thoughts would be much appreciated.

Thanks in advance.
Avatar of monosodiumg

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers