F folsd Member Feb 24, 2023 #1 Hello, I need to parse string that return from our web service. when i invoke this service i get this string ; <int xmlns="http://tempuri.org/">3</int> How can i get "3" from this string in label text thank you Attachments Untitled.jpg 123.6 KB · Views: 487
Hello, I need to parse string that return from our web service. when i invoke this service i get this string ; <int xmlns="http://tempuri.org/">3</int> How can i get "3" from this string in label text thank you
B Brian Dean Well-Known Member Licensed User Longtime User Feb 25, 2023 #2 You could either use string functions ... B4X: Dim s As String = $"<int xmlns="http://tempuri.org/">3</int>"$ Dim p As Int = s.IndexOf(">") Dim q As Int = s.IndexOf2("<", p) Log(s.SubString2(p+1, q)) .. or you could use Regex. I am not very good at Regex. The expression "\>[0-9]+\<" will pick out all the numerals between > and <, including the < and > characters, but somebody else can probably do better than this. Upvote 0
You could either use string functions ... B4X: Dim s As String = $"<int xmlns="http://tempuri.org/">3</int>"$ Dim p As Int = s.IndexOf(">") Dim q As Int = s.IndexOf2("<", p) Log(s.SubString2(p+1, q)) .. or you could use Regex. I am not very good at Regex. The expression "\>[0-9]+\<" will pick out all the numerals between > and <, including the < and > characters, but somebody else can probably do better than this.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Feb 25, 2023 #3 Have you tried this. [B4X] Xml2Map - Simple way to parse XML documents Nobody likes to parse XML. Parsing JSON is simple and fun. Parsing XML is tedious and boring. That is the reason behind the Xml2Map class. It internally parses the XML document and returns a Map with the parsed data. It is similar to parsing JSON. Tip: You can use this tool to help you with... www.b4x.com Upvote 0
Have you tried this. [B4X] Xml2Map - Simple way to parse XML documents Nobody likes to parse XML. Parsing JSON is simple and fun. Parsing XML is tedious and boring. That is the reason behind the Xml2Map class. It internally parses the XML document and returns a Map with the parsed data. It is similar to parsing JSON. Tip: You can use this tool to help you with... www.b4x.com