Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1002861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:53:22+00:00 2026-05-16T07:53:22+00:00

I’m wondering if this is possible. I have html like so: <p> <font face=Georgia>

  • 0

I’m wondering if this is possible.

I have html like so:

<p>
  <font face="Georgia">
    <b>History</b><br>&nbsp; <br>Two of the polysaccharides used in the manufacture of...</font>
    <a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank">
    <font face="Georgia">) and this web site for new development by...well as Self Affirmed Medical Food GRAS status.&nbsp; 
    </font>
</p>

<p>
  <font face="Georgia">[READMORE]</font>
</p>

<p><font face="Georgia"><br><strong>Proprietary Composition</strong><br>
   <br>The method in which soluble fibres are made into... REST OF ARTICLE...
</p>

Yes, it’s ugly html and it comes from a WYSIWYG so I have little control over it.

What I want to do is search for [READMORE] in the document, remove any parent tags ( in this case, the <font> and the <p> tags ) and replace them with a readmore link while wrapping the REST of the document in a giant `…rest of article…

I’m pretty sure the HtmlAgilityPack will get me part of the way there, but I’m just trying to figure out where to start.

So far, I’m pretty sure that I have to use htmlDoc.DocumentNode.SelectSingleNode(//p[text()="[READMORE]"]) or something. I’m not too familiar with XPATH.

For my documents, the readmore may or may not be in a nested font tag.

Also, in some cases, it may not be in a tag at all, but rather at the document root. I can just do a regular search and replace in that case and it should be straightforward.

My ideal situation would be something like this (PSEUDOCODE)

var node = SelectNodeContaining("[READMORE]").

node.Replace( "link here" );

node.RestOfDocument().Wrap("<div class='wrapper'");

I know, I’m dreaming… but I hope this makes sense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:53:23+00:00Added an answer on May 16, 2026 at 7:53 am

    Here is an XSLT solution:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="p[descendant::text()[. = '[READMORE]']]">
      <a href="#ReadmoreWrapper">READMORE</a>
      <div class="wrapper" id="#ReadmoreWrapper">
       <xsl:apply-templates select="following-sibling::node()" mode="copy"/>
      </div>
     </xsl:template>
    
     <xsl:template match=
      "node()[ancestor::p[descendant::text()[. = '[READMORE]']]
             or
              preceding::p[descendant::text()[. = '[READMORE]']]
              ]
      "/>
    
      <xsl:template match="node()|@*" mode="copy">
          <xsl:copy>
           <xsl:apply-templates select="node()|@*" mode="copy"/>
          </xsl:copy>
      </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the following XML document:

    <html>
    <p>
      <font face="Georgia">
        <b>History</b><br/>&#xA0; <br/>Two of the polysaccharides used in the manufacture of...</font>
        <a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank"/>
        <font face="Georgia">) and this web site for new development by...well as Self Affirmed Medical Food GRAS status.&#xA0;
        </font>
    </p>
    
    <p>
      <font face="Georgia">[READMORE]</font>
    </p>
    
    <p><font face="Georgia"><br/><strong>Proprietary Composition</strong><br/>
       <br/>The method in which soluble fibres are made into... REST OF ARTICLE...
       </font>
    </p>
    
    </html>
    

    the wanted result is produced:

    <html>
        <p>
            <font face="Georgia"><b>History</b><br/>  <br/>Two of the polysaccharides used in the manufacture of...</font>
            <a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank"/>
            <font face="Georgia">) and this web site for new development by...well as Self Affirmed Medical Food GRAS status. 
        </font>
        </p>
        <a href="#ReadmoreWrapper">READMORE</a>
        <div class="wrapper" id="#ReadmoreWrapper">
            <p>
                <font face="Georgia"><br/><strong>Proprietary Composition</strong><br/><br/>The method in which soluble fibres are made into... REST OF ARTICLE...
       </font>
            </p>
        </div>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.