Look into this xml file:
<xml>
<head>
<title>Something</title>
</head>
</xml>

I need to store all the string from the tags into an array.
So my string array is supposed to be
[xml,head,title,/title,/head,/xml].

I've tried various methods and read up regular expressions tutorial for C#, but I can't get the string that I wanted.
Here is the code:

string ser = Regex.Replace(d[s], "[^<.*?>]", string.Empty);
MessageBox.Show(ser);

Any help will be appreciated thanks.

See if something like this will work for you:
(tags is a List<string>)

XmlReader xmlr = XmlReader.Create("Yourfilenamehere");
while (xmlr.Read())
{
  if (xmlr.NodeType == XmlNodeType.EndElement)
      tags.Add("/" + xmlr.Name);
  else
      tags.Add(xmlr.Name);
                
}

Then loop through and delete all the empty entries. After that use the string's replace method (I suppose you could use the RegEx one in one step) twice, once replacing "[" with "" and once replacing "]" with "".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.