Solved

xml string

Posted on 2006-11-28
3
256 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now