Remove XAML XML information |
Post Reply |
Author | |
tobi
Senior Member Joined: 09 September 2004 Location: Germany Status: Offline Points: 451 |
Post Options
Thanks(0)
Posted: 01 June 2009 at 1:05pm |
Does anybody know a simple way to remove the XAML xml information from a
styled item ? I have a listbox with XAML formatted entries and need to get the text which is displayed in the listbox only ! |
|
Boris
Senior Member Joined: 21 June 2007 Location: United Kingdom Status: Offline Points: 179 |
Post Options
Thanks(0)
|
Hi
I have this if it helps.
Function TextFromXAML(sXaml As String) As String
Dim find% Dim p Dim txt As String find% = InStr(sXaml, "</Run") If find% <= 0 Then find% = InStr(sXaml, "</TextBlock")
If find% > 0 Then txt = Left(sXaml, find% - 1) p = Split(txt, ">") txt = CStr(p(UBound(p))) TextFromXAML = txt End If End Function |
|
Boris
Product: Xtreme SuitePro (ActiveX) version 16.4.0 16.3.1 Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP6 VS 2005-2008-2010-2013 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
It turns out that this is a trickier problem than it first appears! For example, Boris' method fails if the TextBlock contains <LineBreak/> tags, or if the TextBlock has been defined like:
<TextBlock Text='This is a test'/> It also won't reverse entity encodings such as & and £ . It is still a very useful function as long as you keep your XAML within a specific definition though (I'm not knocking it, just pointing out some potential pitfalls). I'm working on a more general algorithm now, and I will post it when it is available. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Boris
Senior Member Joined: 21 June 2007 Location: United Kingdom Status: Offline Points: 179 |
Post Options
Thanks(0)
|
Hi jpbro,
I have been a little lazy. This was a piece of code that I use to split out the known elements I have used to add to combos amd list boxes in one of my apps. If you do come up with a more global version I would like to see this as I have only coded this for my own specific needs. But, it does show that CJ could add a very useful property to some of the controls.
CJ are you reading this?
Best regards,
|
|
Boris
Product: Xtreme SuitePro (ActiveX) version 16.4.0 16.3.1 Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP6 VS 2005-2008-2010-2013 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Hey guys,
Here's my first attempt at a XAML > Plaintext converter: https://forum.codejock.com/forum_posts.asp?TID=14928&PID=51713#51713 Bug reports, questions and ideas are welcome. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Boris
Senior Member Joined: 21 June 2007 Location: United Kingdom Status: Offline Points: 179 |
Post Options
Thanks(0)
|
That looks fairly compreshensive!
Well done.
If I need to use a lot more XML in my lists I'll definately try using this rather than my version.
Thanks jpbro
|
|
Boris
Product: Xtreme SuitePro (ActiveX) version 16.4.0 16.3.1 Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP6 VS 2005-2008-2010-2013 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Thanks Boris!
I just made a few bug fixes and re-uploaded the source to the same post as before...I hope it comes in handy some day! |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |