Solved

xml string

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

751 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