locked
Automatic be bold character string?

    Question

  • On html: I get a character : “The Theory of Everything,” may have a few more magic tricks up his sleeve. Sources tell Variety that Redmayne is the favorite to play Newt Scamander in Warner Bros.’ hotly-anticipated “Harry Potter” spin-off, “...

    When I will process it by html agility pack(using LINQ) then It be show off:

    “The Theory of Everything,” may have a few more magic tricks up his sleeve. Sources tell Variety that Redmayne is the favorite to play Newt Scamander in Warner Bros.’ hotly-anticipated “Harry Potter” spin-off, “...

    I want these bold character on html when take down on my app then still keep bold character(or color). Can it be do that?

    foreach(var pos in pos_block)
                            {
                           //get header, pronunciton
                                var pronuncationuk=pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sound audio_play_button pron-icon uk");
                                var pronuncationus=pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sound audio_play_button pron-icon us");
                                var pos_head = pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "pos-head");                               
    
                                ////
                                ////
                                ////    
    
                                    var id = pos.Descendants("div").Where(x => x.GetAttributeValue("class", "") == "sense-block");
                                    if(id!=null)
                                    {
                                        foreach(var node in id)
                                        {
                                            result = new ResultToSearch();
                                            var span_h2 = node.Descendants("h2").FirstOrDefault(x => x.GetAttributeValue("class", "") == "");
                                            var sense_body = node.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sense-body");
                                            if(j==1)
                                            {
                                                if(section_title!=null)
                                                {
                                                    result.vocabulary = section_title.InnerText.Trim();
                                                }
                                                if(pronuncationuk!=null)
                                                {
                                                    result.pronunciationuk = pronuncationuk.GetAttributeValue("class","");
                                                    result.iconuk = "/Photos/uk.png";
                                                }
                                                if(pronuncationus!=null)
                                                {
                                                    result.pronunciationus = pronuncationuk.GetAttributeValue("class", "");
                                                    result.iconus = "/Photos/us.png";
                                                }
                                                if(pos_head!=null)
                                                {
                                                    result.poshead = pos_head.InnerText.Trim();
                                                }
    
                                            }
                                            if(span_h2!=null)
                                            {
                                                result.senseblockh2 = span_h2.InnerText.Trim();
                                            }
                                            if(sense_body!=null)
                                            {
                                                result.sensebody = sense_body.InnerText.Trim();
                                            }
                                            arrays.Add(result);
                                        j++;
                                    }
                                   //
    
                                }
                                 //                                   
                                j=1;
     I want make it there"
     result.sensebody = sense_body.InnerText.Trim();

    Saturday, April 11, 2015 1:01 PM

Answers

  • Hi Greg,

    Which control you would like to display these HTML codes?

    If you would like to display them on RichTextBlock, probably you have to apply the <bold> tag in the <paragraph>, you can find sample from: RichTextBlock class

    Here also a short code snippet for your reference:

        <RichTextBlock Grid.Column="0" IsTextSelectionEnabled="True" TextAlignment="Justify" 
                       OverflowContentTarget="{Binding ElementName=firstOverflowContainer}" 
                       TextIndent="12"
                       FontSize="12" FontFamily="Segoe UI" Foreground="#2a2a2a" Margin="20,0">
            <Paragraph>
                <Bold><Span Foreground="DarkSlateBlue" FontSize="16">Lorem ipsum dolor sit amet</Span></Bold>, consectetur adipiscing elit. Sed ac mi ipsum. Phasellus vel malesuada mauris. Donec pharetra, enim sit amet mattis tincidunt, felis nisi semper lectus, vel porta diam nisi inurna, venenatis ac adipiscing vel, congue at lectus. Proin ac metus at quam luctus ultricies.
            </Paragraph>
            <Paragraph>
                <Italic>This is an inline image.</Italic>
                <InlineUIContainer>
                    <Border Background="Black">
                        <Image Source="Assets/SmallLogo.png" Height="30" Width="30"/>
                    </Border>
                </InlineUIContainer> 
                . Nullam aliquet pellentesque convallis. Ut vel tincidunt nulla. Mauris auctor tincidunt auctor.
            </Paragraph>
    

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 13, 2015 1:58 AM
    Moderator