I was able to pull everything from the wall, but it all came as one long string with no html line breaks <br/>. Seems simple enough to fix, right? I ususally append a .Replace(vbCrLf, "<br/>") to my string and I'm golden, but that wasn't working this time.
I tried everything I could think of: vbCrLf, Environment.NewLine, \n, \r\n, \r, Chr(13), PHP_EOL, ControlChars.NewLine, ControlChars.CrLf - nothing seemed to be working until I finally tried out vbLf
The vbLf constant represents \n just as vbCr represents \r and vbCrLf represents \r\n. Facebook uses the \n notation to store line breaks.
So if I were to store my FQL (Facebook Query Language) query results in a string called myFqlResult, I could print it out to the screen in a decent viewing manner with the string:
lblMyExample.Text = myFqlResult.Replace(vbLf,"<br/>")
Facebook also throw in all sorts of xml structures as well, so I usually filter it all out with something like this:
lblMyExample.Text = myFqlResult.Replace("<message>", "<p>")_
.Replace("</message>", "</p>")_
.Replace("<stream_post>", "<div>")_
.Replace("</stream_post>", "</div>")_
.Replace(vbLf, "<br/>")_
.Replace("<fql_query_response xmlns=""http://api.facebook.com/1.0/"" _
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" list=""true""><br/>", "")_
.Replace("</fql_query_response><br/>", "")_
.Replace("<?xml version=""1.0"" encoding=""UTF-8""?><br/>", "")_
.Replace("<div><br/>", "<div>")
0 comments:
Post a Comment