Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Remove XAML XML information
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Remove XAML XML information

 Post Reply Post Reply
Author
Message
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Topic: Remove XAML XML information
    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 !


Back to Top
Boris View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 June 2007
Location: United Kingdom
Status: Offline
Points: 179
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boris Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2009 at 9:51am
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2009 at 12:02pm
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 &amp; and &#163; . 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

Back to Top
Boris View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 June 2007
Location: United Kingdom
Status: Offline
Points: 179
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boris Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2009 at 12:16pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2009 at 2:29pm
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

Back to Top
Boris View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 June 2007
Location: United Kingdom
Status: Offline
Points: 179
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boris Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2009 at 2:46pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2009 at 4:00pm
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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.176 seconds.