Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
XML
<NUM_AE>147</NUM_AE>
string
i need to get the value 147
How its possible?
thanks in advance
Posted
Comments
Maciej Los 1-Oct-15 4:44am    
Why your xml file is messed up? What have you tried to parse it? Please, provide complete xml structure and data.

C#
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[^]
 
Share this answer
 
v2
 
Share this answer
 
Comments
Maciej Los 1-Oct-15 8:16am    
Please, read the question again. Seems your answer does not correspond to OP's issue .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900