Solved

xml string

Posted on 2006-11-28
3
258 Views
Last Modified: 2013-11-19
i want to retrieve the tag value from the xml string without load it into xml document.

Is possible? how?
0
Comment
Question by:Rahamathulla_J
  • 2
3 Comments
 
LVL 23

Expert Comment

by:adathelad
ID: 18026774
Hi Rahamathulla_J,

It can be done either using some string manipulation or potentially complex regular expressions (depending on how complex it needs to be -i.e. do you need to extract a value from a node nested so many levels down  in the document), but is there a reason why you can't load it into an XMLDocument object?

It would save you reinventing the wheel.

0
 
LVL 3

Accepted Solution

by:
ankitbansal earned 250 total points
ID: 18206638
Hey!

If you only need to retrieve name of tags then that can be done by reading the xml as a string.
Read that string fowrard by using IndexOf method of string passing "<" as parameter. This would give you index of starting tag read it till indexof(">") (in this way you will get the tag name), then delete the string read so far... keep repeating this in a loop till end of the string.

You can also use a simple regular expression to search for strings of format "<a-zA-Z>". remember this is not the regular expression but the format that u would search for.

Regards'
Ankit
0
 
LVL 3

Expert Comment

by:ankitbansal
ID: 18206698
here is a regular expression that would match any tag without attribute and starting with a alphabet!

<[A-Za-z][A-Za-z0-9]*>

and this reg exp would match anytag (ofcource without attribute) <[A-Za-z0-9]*>
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question