login about faq

I’m using your latest library with Visual Studio 2013 Professional. I’m coding in VB.net

But when i try to covert from HTML/URL to txt it works fine, even HTML File to XML works fine but URL to XML is giving following error:

System.InvalidCastException was unhandled HResult=-2147467262 Message=Conversion from string "<!DOCTYPE html> <html lang="en">" to type 'Integer' is not valid. Source=Microsoft.VisualBasic StackTrace: at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) at Rectified.netHTML2XML2XT.Form1.cmdConvert_Click(Object sender, EventArgs e) in machomedocumentsvisual studio 2013ProjectsRectified.net - HTML2XML2XTRectified.net - HTML2XML2XTForm1.vb:line 148 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at Rectified.netHTML2XML2XT.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) at System.Activator.CreateInstance(ActivationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.FormatException HResult=-2146233033 Message=Input string was not in a correct format. Source=Microsoft.VisualBasic StackTrace: at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) InnerException:

Here is the related code:

If rdURL.Checked Then If txtURL.Text <> "" Then Dim http As New Chilkat.Http() Dim html As String

                html = http.QuickGetStr(txtURL.Text)
                If (http.LastMethodSuccess <> True) Then
                    txtResults.Text += http.LastErrorText + vbCrLf
                    Exit Sub
                End If

                Dim h2x As New Chilkat.HtmlToXml()
                Dim strHTML As String
                Dim strXML As String
                strHTML = html

                strXML = h2x.ToXml(strHTML)
                success = h2x.WriteStringToFile(strXML, strSaveFilePath, "utf-8")
                If (success <> True) Then
                    txtResults.Text += chilkatGlob.LastErrorText + vbCrLf
                    txtResults.Text += strFilePath + " Successfully converted from HTML to XML File " + strSaveFilePath
                End If

            End If

        End If

I’m trying it with http://rectified.net

even sent email to support


asked Aug 19 '16 at 10:55

funtoosh's gravatar image


Have a look at the online reference documentation here:

The ToXml method takes 0 arguments.
This is incorrect:

strXML = h2x.ToXml(strHTML)

This is correct:

h2x.Html = strHTML
strXml = h2x.ToXml()


answered Aug 19 '16 at 11:03

chilkat's gravatar image

chilkat ♦♦

edited Aug 19 '16 at 11:03

Thanks it worked

(Aug 19 '16 at 11:49) funtoosh
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 19 '16 at 10:55

Seen: 2,045 times

Last updated: Aug 19 '16 at 11:49

powered by OSQA