Home > Back-end >  C# Split string by tag and create an iterable data structure
C# Split string by tag and create an iterable data structure

Time:04-19

I have this string:

<item>
  <node1>Name</node1>
    <childNode1>Nickname</childNode1>
  <node2>Surname</node2>
</item>
<item>
  <node1>AnotherName</node1>
  <node2>AnotherSurname</node2>
</item>

I want to split this string by "item", and create a data structure from text extracted from all nodes, for example: {"Name","Nickname", "Surname"}

{"Name", "Surname"}

CodePudding user response:

While adding a root element, in order to create an XML might be better

  •  Tags:  
  • c#
  • Related