Solved

xml string

Posted on 2006-11-28
3
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

626 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