[英]C# split XML InnerText
I have a .graphml file which is based on the XML data format but allows us to represent graph structures.我有一个基于XML数据格式的.graphml文件,但允许我们表示图形结构。 My problem is that I have many InnerText Elements in one Node and need to split them into an array.
我的问题是我在一个节点中有许多 InnerText 元素,需要将它们拆分为一个数组。
...<y:AttributeLabel xml:space="preserve">+Name +Age -Id</y:AttributeLabel>...
From this example, I need +Name , +Age and -Id separately stored in an array.在这个例子中,我需要将+Name 、 +Age和-Id分别存储在一个数组中。 Can anyone help me out?
谁能帮我吗?
Btw the .graphml file is huge.顺便说一句,.graphml 文件很大。
If you don't like regex:如果你不喜欢正则表达式:
string[] nameAgeId = InnerText.Split(' ')
.Select(x => x.Trim('+', '-')
.ToArray();
string splitOn = @"[\s+-]+";
string[] stringArray= Regex.Split(InnerText, splitOn);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.