Reading xml

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey all,

If I wanted to read only certain records from an xml file, where do i begin
my search to find out how to do that?

thanks,
rodchar
 
Check out the System.Xml namespace and then check out XPath. The various
classes in System.Xml (XmlDocument will probabaly be the easiest to use right
off the bat) can help you load the XML file and XPath is the syntax to run
queries against your XML to get subsets of the data.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
If I wanted to read only certain records from an xml file, where do i
begin
my search to find out how to do that?

Probably using the XPathNavigator:

Here's a snippet of code from a project of mine:

dim XMLfilename As String = (MapPath("/districts/" & siteID &
"/xml/siteMenu.xml"))
Dim xpd As XPathDocument = New XPathDocument(XMLfilename)
Dim xpn As XPathNavigator = xpd.CreateNavigator()
' set globalMenuCategory
dim expr as XPathExpression =
xpn.Compile("//menuCategory[../descendant-or-self::pageID = '" & pageID &
"']")
dim ni as XPathNodeIterator = xpn.Select(expr)
ni.MoveNext()
if ni.Current.Value <> "" then
'globalMenuCategory = ni.Current.Value
else
'globalMenuCategory = "null"
end if

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

xml and its stylesheet 2
can rss do this 2
my html code 3
finding a textbox with a search string 4
static vs appsession 3
when page timeout 4
finding an element on a page 8
label wrapping 2

Back
Top