pat said:
I'll check those out, here is the code i found for C#, looks like I
misread it because its was created by someone else and just named
GetStringInBetween. Oops!
public static string[] GetStringInBetween(string strBegin,
Hi pat, you are over thinking the solution
The technology is already
there for this.
When it comes to HTML, understanding DOM is useful.
If the application is on the client side (browser), then you can just pure
JavaScript or JSCRIPT or VBSCRIPT to access the Document.* methods and
properties and events.
var tag = document.GetElementById("myclass")
but that finds a tag id=value, i.e.
<span id="myclass">...</span>
DOM has GetElementByTag and GetElementByName, but no GetElementByClass().
So there are advanced javascripts using prototyping methods specifically
designed for searching the HTML DOM and manipulating it. This is whats
making WEB 2.0 happen (that along with AJAX). You have hundreds of open
source prototype javascript libraries, among them are I know and use:
prototype.js which started the idea (I think)
jquery.js probably the best and fastest based on prototype.js
There are others too but I think they are bulky.
In fact, jQuery is so small, fast and sweet, Microsoft has announced full
jQuery support in ASP.NET. Its being add for VS2010 (or already was for
VS2008).
jQuery will allow you to find anything using a CSS style lookup and XPATH
as well. Off hand, to find the <span class="myclass"> the command would
be:
var value = $("span.class")[0].innerHTML;
I think that is correct syntax, if not, its close.
Again, thats the client side.
For the server-side, you can use the .NET System.XML.XPath library
assembly as I showed in the previous post.
Kind in mind that a Class is a attribute which other span tags or any tag
can have. In general, using ID or Name is more unique. Nonetheless, in
all cases, the search can result in a list as shown in the example I
provided. If you expect only one, use the first index.
Finally, as Tom has highlighted in similar XML/HTML query questions,
Microsoft's LINQ is a new simply query language that plays off SQL-like
commands to find stuff. So you might want to explore LINQ as well.
--