Link to home
Start Free TrialLog in
Avatar of MJRoberts
MJRobertsFlag for Canada

asked on

XML Datafile

Hello experts,

I have a 30meg+ staic XML datafile. What I need to do is read only one node from that data file into memory. That data node will only at most  2 or 3k in size. I do not have to load any other portion of the XML file into memory other than the found node. What are my fasted (performance) options. The method I was using was loding the entire document into memory before any node searching occured. Yikes, that was slow and really did not find the required node. I was using an XMLDocument like below

      Dim doc As XmlDocument = New XmlDocument
      Dim output As String = ""

      Try
         doc.Load(System.Web.HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings("Layout-FileName")))
         output = doc.SelectSingleNode("//LAYOUT-TYPE[@Name='" & layoutName & "']" & _
                                  "//LAYOUT[@Name='" & layout& "']" & _
                                  "//TABLE[@Name='" & table & "']").OuterXml
      Catch ex As Exception
         Debug.WriteLine(ex)
      End Try


Loading this enitre document into memory is just plain bad idea. It is extremely slow. One need to read this file like and pick the required node. The problem is I am new at XML and don't know how to do this.


Thanks all
Mark
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial