Easily find tags and values in a large xml document using XmlTextReader in VB
In this article you will learn how to find tags and values in a large xml document using XmlTextReader in VB.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Easily find tags and values in a large xml document using XmlTextReader in VB


Murari YalamanchilyeditedPosted Feb 29, 2012, 12:30 PM ESTEdited Feb 29, 2012, 12:31 PM EST
How do I loop through the file using xpath navigator and first get dr-nbr for first record and as the first record does not have bidder info so go to bidder info which is in sub node in second record. See the xml data shown below <reports> <report> <xml-report> <summary> <dr-nbr>2012004</dr-nbr> </summary> <data> <proj-title> <title-code> <title ci = "N">District 321</title> </title-code> </proj-title> <p-location> <project-location> <title-code> <p-county-name ci = "N">BOOLE</p-county-name> <p-fips-county>MT101</p-fips-county> <p-city-name ci = "N">MTELBY</p-city-name> <p-state-id ci = "N">MT</p-state-id> <p-zip-code ci = "N">69474</p-zip-code> <p-zip-code5 ci = "N">69474</p-zip-code5> <p-country-id ci = "N">USA</p-country-id> </title-code> </project-location> <pct-project-county> <title-code> <p-county-name ci = "N">TOOLE</p-county-name> <p-fips-county>MT101</p-fips-county> <p-state-id>MT</p-state-id> <p-country-id>USA</p-country-id> </title-code> </pct-project-county> </p-location> <status> <title-code> <status-proj-dlvry-sys ci = "N">Design-Bid-Build</status-proj-dlvry-sys> </title-code> </status> </data> </xml-report> </report> <report> <xml-report> <summary> <dr-nbr>2011005</dr-nbr> </summary> <data> <proj-title> <title-code> <title ci = "N">Plane Pitch</title> </title-code> </proj-title> <p-location> <project-location> <title-code> <p-county-name ci = "A">SUMMIT</p-county-name> <p-fips-county>MI153</p-fips-county> <p-city-name ci = "A">AVON</p-city-name> <p-state-id ci = "A">MI</p-state-id> <p-zip-code ci = "C">44308</p-zip-code> <p-zip-code5 ci = "C">44308</p-zip-code5> <p-country-id ci = "A">USA</p-country-id> </title-code> </project-location> <pct-project-county> <title-code> <p-county-name ci = "A">SUMMIT</p-county-name> <p-fips-county>OH153</p-fips-county> <p-state-id>OH</p-state-id> <p-country-id>USA</p-country-id> </title-code> </pct-project-county> </p-location> <project-bidder-information> <title-code> <bid-header> <bid-header-desc ci = "N">Low Bidders</bid-header-desc> <bid-title> <bid-details> <contact-information> <firm-name>Many Stocks</firm-name> <contact-name>Many Moree</contact-name> </contact-information> </bid-details> <bid-details> <contact-information> <firm-name>Who Constrcution</firm-name> </contact-information> </bid-details> </bid-title> </bid-header> </title-code> </project-bidder-information> </data> </xml-report> </report> </reports> I am able to get bidder info like this but how to know it is for which project Dim BidCompanyiter As XPathNodeIterator BidCompanyiter = nav.Select("reports/report/xml-report/data/project-bidder-information/title-code/bid-header/bid-title/bid-details/contact-information/firm-name") While BidCompanyiter.MoveNext 'Get the data we need from the node lstNav = BidCompanyiter.Current iterNews = lstNav.SelectDescendants(XPathNodeType.Element, False) 'Loop through the child nodes Response.Write(iterNews.Current.Name & ": " & iterNews.Current.Value) Response.Write("<BR>") Exit While End While
John DoePosted May 13, 2009, 6:32 PM EDT
Great job!