且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从xml字符串中获取值

更新时间:2022-10-15 09:45:19

  string  inputString =   asjkdfkas djasdasdjasjd<> sfkasdfkaslkfa< NUM_AE> 147< / NUM_AE>< b> sdfsdfsdf< / b> sdfsdfsdfsdf; 
正则表达式正则表达式= 正则表达式( < ; NUM_AE&GT;&LT(*); / NUM_AE>中跨度>);
var regMatch = regex.Match(inputString);
string value = regMatch.Groups [ 1 跨度>]的ToString();



检查 RegEx C#:查找2个已知值之间的字符串 [ ^ ]


查看下面的链接



http:/ /***.com/questions/18250671/how-to-read-single-node-value-from-xml-file

Hi Friends

I need to find a value from an XML string. since my Xml string is messed up i am not able to parse. so my question is, whether with help of some regex expression or using any other way can i pick up the value
For example this is my

<NUM_AE>147</NUM_AE>

string
i need to get the value 147
How its possible?
thanks in advance

string inputString ="asjkdfkas djasdasdjasjd<>sfkasdfkaslkfa<NUM_AE>147</NUM_AE><b>sdfsdfsdf</b>sdfsdfsdfsdf";
Regex regex = new Regex("<NUM_AE>(.*?)</NUM_AE>");
var regMatch = regex.Match(inputString);
string value = regMatch.Groups[1].ToString();


check RegEx C# : Find a string between 2 known values[^]


have a look at below link

http://***.com/questions/18250671/how-to-read-single-node-value-from-xml-file