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 233933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:08:38+00:00 2026-05-11T20:08:38+00:00

This is an extension of this question . I’m trying to parse HTML snippets

  • 0

This is an extension of this question. I’m trying to parse HTML snippets embedded in an XML backup of a Blogger blog and retag them with InDesign tags.

Blogger doesn’t standardize the HTML for any of its posts, and the posts can be written in Word, Windows Live Writer, the native Blogger interface, or text editors, resulting in tons of different forms of HTML. Some posts don’t mark paragraphs and only use double <br>s in between paragraphs—others use actual <p> tags.

What’s the best way to parse this unstandard conglomeration of tags?

Additionally, each post is not a complete HTML file–just a snippet that gets inserted into a template—which means that there is no overall HTML structure to parse (<html><body></body></html>, etc.) Does that have any effect on XML/HTML parsing?

Here’s some potential examples, mostly standard HTML, missing paragraphs:

This is a section of a blog post. It has <a href="#">links</a> and lists and stuff. Weee....
<br>
<br>
Here's a list
<br/>
<br />
<ul><li>Item 1</li><li>Item 2</li><ul>
And another paragraph here...
<br>
<br/>
Etc.

The Word HTML looks like this – http://www.timeatlas.com/mos/images/stories/word_html_tags.png

  • 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-11T20:08:38+00:00Added an answer on May 11, 2026 at 8:08 pm

    The HTML generated by Word is relatively easier to deal with. I would just get rid of all the tag attributes (unless you care about styles). That would live you with fairly plain HTML which you can then style.

    HTML::TokeParser::Simple can help make that relatively painless.

    As for the other stuff, that will take some trial and error. I am going to think more about that and post later if I can think of something clever.

    Later Update:

    Well, here is something that makes me cringe a little but it seems to work:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use File::Slurp;
    use Text::Markdown qw( markdown );
    
    my $html = read_file \*DATA;
    
    $html =~ s{(?:<br(:? ?/)*>)}{\n\n}g;
    
    print markdown( $html );
    
    __DATA__
    This is a section of a blog post. It has <a href="#">links</a> and lists and stuff. Weee....
    <br>
    <br>
    Here's a list
    <br/>
    <br />
    <ul><li>Item 1</li><li>Item 2</li></ul>
    And another paragraph here...
    <br>
    <br/>
    

    Output:

    <p>This is a section of a blog post. It has <a href="#">links</a> and lists and
    stuff. Weee....</p>
    
    <p>Here's a list</p>
    
    <ul><li>Item 1</li><li>Item 2</li></ul>
    
    <p>And another paragraph here...</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As an extension of this question , I'm trying to insert Javascript to a
This is an extension of question: Order of the initialization in Java so in
This is an extension of a question I previously asked here . Long story
This is an extension to a question which I asked some time ago. I
This is an extension for this question asked an hour ago. We cannot modify
This is an extension of this question and probably might even be a duplicate
This is an extension to the question I asked here: Get text from clipboard
This is an extension of this question: SQLite problem selecting two columns as one
As an extension to this question here Linking JavaScript Libraries in User Controls I
This is something of an extension to this question: Dispatching to correct function with

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.