Why is my ITexthandler not working? I'm trying

2019-06-17 02:55发布

问题:

I’m using Visual Developer 2010, MVC 3, c#. I’m trying to parse XML into an iTextSharp document like this:

        ITextHandler textHandler = new ITextHandler(doc);
        textHandler.Parse(xmldoc);

The error message says ITextHandler is not in this context. How can I make this work? Or is there another constructor that will do the same thing?

Here’s my list of using statements:

using System;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using iTextSharp.text;
using iTextSharp.text.xml;
using iTextSharp.text.pdf;

Everything else seems to compile properly except for the ITextHandler line. Please help.

回答1:

ITextHandler is part of iText and iTextSharp 4.x series but was removed from the 5.x series in favor of iTextSharp.text.xml.simpleparser.SimpleXMLParser. In recent months, however, another project has been gaining favor for XML and HTML parsing. Most, if not all XML and HTML work going forward is being done in the separate library xmlworker found here. With in that library you'll find the iTextSharp.tool.xml.parser.XMLParser class.