473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

XML Node Wildcard?

I'm using the following to pull a string from an XML Log file:

Public Sub ReadXMLFile()
Dim xmlDoc As New XmlDocument
xmlDoc.Load("d:\test.xml")
Dim DriveError As String =
xmlDoc.SelectSingleNode("/joblog/backup/set/directory/directory/director
y/drive_error").InnerText
MsgBox(DriveError)
End Sub

However, the "drive_error" part of the node could be any number of
"directory"'s deep depending on where the error occurred during the
backup.

Is there a wildcard or some other way I could grab the drive_error text
regardless of how deep it is?

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
1 1734

"Terry Olsen" <to******@hotmail.com> wrote in message
news:eE**************@TK2MSFTNGP09.phx.gbl...
:
: I'm using the following to pull a string from an XML Log file:
:
: Public Sub ReadXMLFile()
: Dim xmlDoc As New XmlDocument
: xmlDoc.Load("d:\test.xml")
: Dim DriveError As String =
: xmlDoc.SelectSingleNode(
: "/joblog/backup/set/directory/directory/director
: y/drive_error").InnerText
: MsgBox(DriveError)
: End Sub
:
: However, the "drive_error" part of the node could be any number of
: "directory"'s deep depending on where the error occurred during the
: backup.
:
: Is there a wildcard or some other way I could grab the drive_error
: text regardless of how deep it is?
:
: Thanks.
:
: *** Sent via Developersdex http://www.developersdex.com ***
Yes: "/joblog/backup/set/*//drive_error"
Assume your xml document looks like this:
---------------------------------------------------
<joblog>
<backup>
<set>
<directory>
<directory>
<directory>

<!-- 3 directories deep -->
<drive_error>SomeValue</drive_error>
</directory>
</directory>
</directory>
</set>
<set>
<directory>
<directory>
<!-- 2 directories deep -->
<drive_error>SomeOtherValue</drive_error>
</directory>
</directory>
</set>
</backup>
</joblog>
---------------------------------------------------
This code will access both drive_error nodes even though they aren't
nested as deeply.

---------------------------------------------------
Option Strict

Imports System
Imports System.XML

Public Class [Class]
Public Shared sub Main()
Dim x As New XMLDocument
Dim node As XMLNode
Const xPath As String = _
"/joblog/backup/set/*//drive_error"

x.Load("tmp.xml")

For Each node In x.selectNodes(xPath)
Console.WriteLine(node.innerText)
Next

End Sub
End Class
---------------------------------------------------

Ralf
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Generic Usenet Account | last post by:
Here's the requirement that I am trying to satisfy: Handle wildcards in STL such that the wildcard entry is encountered before non-wildcard entries while traversing containers like sets and...
1
by: deko | last post by:
I have a form where users can enter a string with asterisks to perform a wildcard search. Currently, the string entered by the user looks like this: *somestring* The purpose is to match any...
3
by: Adam | last post by:
Its my understanding that in asp.net 2.0 you can write an httpmodule that will acts as a wildcard handler and pass requests on to the proper engine, for instance, asp or perl for example, In the...
2
by: Ken Yee | last post by:
First a little background: I've written an httphandler to handle wildcard extensions (i.e., I want to handle all URLs that come in rather than just URLs w/ a specific file extension so I can give...
7
by: SlimFlem | last post by:
I have searched hard for 2 days on this and keep hitting a wall. I have a custom IHttpHandler setup to do Url mappings to prop up some old Urls for our site. I have also created a wildcard...
2
by: Jan Kucera | last post by:
Hi, I have virtual MyFolder/* and MyFolder/MySubFolder/* mapped to an httphandler in the web.config file and all works perfectly on the asp.net development server. However on the IIS6/Win2003 I'm...
2
by: guoqi zheng | last post by:
Dear Sir, I would like all files on my application to pass asp.net, so I added aspnet_isapi.dll to the Wildcard application maps. After that, many things changed. I used to be able to visit my...
6
by: Jan Kucera | last post by:
Hi, does anybody know about wildcard mapping ASP.NET 2 in IIS6? Any tutorial? Thanks, Jan
1
by: Lucvdv | last post by:
In my assembly.vb files, I'm using the revision/build wildcard style: <Assembly: AssemblyVersion("3.0.*")> <Assembly: AssemblyFileVersion("3.0.*")> This onkly seems to work in projects that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.