简体   繁体   中英

C# split XML InnerText

I have a .graphml file which is based on the XML data format but allows us to represent graph structures. My problem is that I have many InnerText Elements in one Node and need to split them into an array.

...<y:AttributeLabel xml:space="preserve">+Name +Age -Id</y:AttributeLabel>...

From this example, I need +Name , +Age and -Id separately stored in an array. Can anyone help me out?

Btw the .graphml file is huge.

If you don't like regex:

string[] nameAgeId = InnerText.Split(' ')
                              .Select(x => x.Trim('+', '-')
                              .ToArray();
string splitOn = @"[\s+-]+";

string[] stringArray= Regex.Split(InnerText, splitOn);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM