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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:14+00:00 2026-05-28T04:31:14+00:00

I am attempting to use XMLParse against content that is not valid xhtml. In

  • 0

I am attempting to use XMLParse against content that is not valid xhtml. In the html code, the tags are not properly terminated. In order to terminate them, I am using the replace function to find the invalid code and replace it with properly terminated code. In doing so, my application errors out and tells me that the meta tag is invalid:

An error occured while Parsing an XML document.

The element type “meta” must be terminated by the matching end-tag “”.

The code I’m trying to validate is:

<html>
<head>
<title>Impart Client Interface</title>
<link href="side_panel.css" rel="stylesheet" type="text/css">
<link href="default.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="data_tables.css" rel="stylesheet" type="text/css">
<link href="xp_button.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

What I’ve created in CF to attempt to handle this is:

<cfset xml = objResponse.FileContent>

<cfset page.content = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'>
<cfset page.updatedcontent = replace('#page.content#','8859-1','8859-1" />"','')>
<Cfset page.link = 'type="text/css">'>
<cfset page.updatedLink = replace('#page.link#', 'css">', 'css" />', 'all')>



<cfset validXML = replace(#xml#, "#page.content#", "#page.updatedContent#", "")>
<cfset validXML = replace(#xml#, "#page.link#", "#page.UpdatedLink#", "all")>
<cfoutput>#validXML#</cfoutput>     

<cfset parsethis = xmlparse(validXML)>

<cfdump var="#parsethis#">

How can I resolve this error?

  • 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-28T04:31:14+00:00Added an answer on May 28, 2026 at 4:31 am

    Looks to me like you are missing part of the substring in your replace call:

    <cfset page.updatedcontent = replace(page.content,'8859-1">','8859-1" />')>
    

    Note the addition of “>

    So, the above will address your specific technical question. I’d like to suggest a better approach to your general task, however. Doing string manipulation on HTML to try to mash it into proper XHTML is tricky at best (as you have seen). Instead, consider abandoning XMLParse in favor of an actual HTML parser, such as JSOUP. After you download the jar and add it to your CF classpath, you can do things like this:

    <cfset jsoup = CreateObject("java", "org.jsoup.Jsoup")>
    <cfsavecontent variable="html">
    <html>
    <body>
    <hr>
    <pre id="blah">Foo<br>bar1</pre>
    <hr>
    <pre id="blah2">Foo<br>bar2</pre>
    </body>
    </html>
    </cfsavecontent>
    
    <cfdump var="#jsoup.parse(html).select('pre').first().html()#">
    

    Which will output :

    Foo<br />bar1
    

    Pretty spiffy, eh? And no need to pull out your hair over getting exact details right with XML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In attempting to use std::select1st from <functional> in a VS2008 project I found that
I'm attempting to use MIB files in PySNMP. The code is fairly straightforward. Nothing
I am attempting to use AJAX in jQuery to load content to a div,
Attempting to use asp.net mvc's Action Result of File. So it would seem that
I am attempting to use Ant's XMLValidate task to validate an XML document against
I'm attempting to use the following code to serialize an anonymous type to JSON:
I am attempting to use the MediaStore.ACTION_VIDEO_CAPTURE in my app, see code below. However,
I'm attempting to use jsoup to sanitize the the html posted from a wysiwyg
I am attempting to use a UISegmentedControl to control the sort order of my
I'm attempting to use Dotfuscator 4.7.1000 to obfuscate a Silverlight library that is strongly

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.