jericho-html-parser


Get error string from Jericho SourceFormatter


I'm using jericho's SourceFormatter to do indentation of HTML.
Right now if there is an issue in my HTML formatter sends it to server console.
How can I catch error and output it into my log system (actually I want to get it as a String/Object)?
Here is example of code I use
private String indent(String html) {
SourceFormatter formatter = new SourceFormatter(new Source(html));
formatter.setIndentString("\t");
formatter.setTidyTags(false);
formatter.setCollapseWhiteSpace(true);
return formatter.toString(); // if HTML have issues, they go to server's consol
}
LoggerProvider - represent loggin system of hericho
I found that it is possible to realize Logger interface and use it as your own logger.
class LoggerCustom implements net.htmlparser.jericho.Logger {
...
}
And than pass it's object to Source object.
Source source = new Source(html);
LoggerCustom logger = new LoggerCustom();
source.setLogger(logger); // here I pass my Logger object.
SourceFormatter formatter = new SourceFormatter(source);
formatter.setIndentString("\t");
formatter.setTidyTags(false);
formatter.setCollapseWhiteSpace(true);
String result = formatter.toString();

Related Links

Get error string from Jericho SourceFormatter
How do I add a hidden input tag using the Jericho HTML Parser?

Categories

HOME
cil
udp
admin-on-rest
itext
backup
decorator
angular2-directives
wampserver
goutte
constructor
wicket
xamarin-studio
xul
intellij-plugin
game-physics
jacoco
bar-chart
thumbnails
avplayeritem
iup
rworldmap
auditing
printdocument
edge-detection
cell-array
lmdb
spring-profiles
ipfw
modelandview
jquery-cycle2
codesys
socketscan
distributed-transactions
datalog
tango
g1gc
worker
filepath
taskmanager
shutdown
ruby-on-rails-2
etherpad
static-code-analysis
mercury
visual-studio-templates
alter
galleriffic
kendo-combobox
contour
gmsmapview
eml
xmp
loopj
android-recyclerview
lemoon
drf-nested-routers
jta
leadtools-sdk
pgm
callstack
xaml-designer
utf-32
boost-test
mfmailcomposeviewcontroll
httpcontext
map-force
mbox
initialization-vector
java.util.date
sslexception
image-zoom
ftp4j
surveyor-gem
arbor.js
sequelpro
caliper
wcf-web-api
subtract
objective-c-protocol
supersized
separation-of-concerns
entity-framework-ctp5
wchar
hashalgorithm
surf
msbuildextensionpack
chatroom
msn
external-assemblies
jquery-ui-button
scatterview
system-codedom-compiler

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App