I have an HTML string that I need to modify its elements.
I looked into NSXMLParser, but didn't see any method to modify the elements while reading them.
I don't like the solution of creating a NSMutableString and adding strings to it.
Is there a way to read HTML string and modify its element in an elegant way?
e.g.,
<div style="color:grey"></div>
will be
<div style="color:black"></div>
Unfortunately I saw that one cannot use NSXMLDocument in an iPhone app.
see the github project KissXML which is a 'clone of NSXML library and works the same.
https://github.com/robbiehanson/KissXML
shameless self-advert: my fork of it works way better with html that's not real xml
https://github.com/Daij-Djan/KissXML
Related
Currently, I am working on a program that converts an html page into a PDF using the iText Library.
The Checker that I am using is PAC3 -->PDF Accessibility Checker 3 which is described by the following link (https://section508.gov/blog/check-pdf).
One of the issues is the “Alternate description missing for an Annotation”
An excerpt from the following link explains it:
http://www.uottawa.ca/respect/sites/www.uottawa.ca.respect/files/fss-fixing-accessibility-errors-in-pdfs.pdf
Alternative description missing for an annotation This usually happens when the link is not clear enough. To fix this error, add alternative text to the link tags. To add the alternative text, please do the following;
In the tag tree, select the tag for the link, and select Properties
from the options menu.
In the Touchup Properties dialog box, select
the Tag Tab.
Type alternate text for the link, and click close
I have been trying to use iText to fix this problem, but googling, looking at the source and reading the documentation does not help.
Does anybody have any suggestions on how to either write the HTML or use the itext problem to get rid of the “Alternate description missing for an Annotation”
Thank you for your help
You did not specify whether you using old code (XMLWorker, HTMLWorker) or new iText code (pdfHTML).
This of course impacts the proposed solution.
In my answer I am going to assume you are using pdfHTML
There are several options:
edit the incoming HTML using a library like JSoup
convert the incoming HTML to iText IElement objects, and edit those, setting properties where needed
write your own custom TagWorker that handles all instances of a specific tag, and write custom logic to deal with the missing annotations.
An example of a custom tag worker can be found here:
https://developers.itextpdf.com/content/itext-7-examples/converting-html-pdf/pdfhtml-custom-tagworker-example
i created a site, And added pages to my site, since page size exceeds i need to create pagination in html i have created this method
123
in this way i created
Problem is when i add new page i need to replace all code again like this
1234
ever time when i add new page i need to replace all code is ther a way to do this without PHP
Can sombody help me any idea to do this in html
Do not re-invent the wheel. Use datatables, they provide sorting, pagination (client side and server side), export and a number of additional features.
http://datatables.net/
Include the files and just add this.
$(document).ready(function() {
$('#example').dataTable();
} );
This is a very basic and good example, you should go for it.
http://datatables.net/examples/data_sources/dom.html
This cannot be done purely in HTML. You must use something like PHP, or you could use Javascript.
You can make just one HTML file called "Pagination.html" include all your links there and then include that Pagination on every page using one of the following methods.
You can use Javascript: javascript
Or you can use html5: html5
Or there are also, others solutions to solve your problem like this: other
You better use some Javascript oriented solution, html5 support for including files still very poor.
unfortunately, this won't be possible without using some other technology that is not HTML. You can dynamically generate pages using javascript (JS), PHP or other technology, but not just raw HTML.
You can name your pages something like:
page_1.html
page_2.html
and then whichever editor you are using probably has a search & replace function, so you could use that to speed up things. I hope this helps.
I use the XML::Twig Perl module to extract a div out of an HTML document, and would like to create a new HTML doc containing only this div, and the required HTML wrapping. I would then also add some CSS styles to the new document.
Extracting the div is easy, but I'm too lazy to write the HTML wrapping around it myself :-).
There surely must be a Perl module which would do that boring part for me. Or maybe even a method in XML::Twig itself, which I overlooked or didn't understand?
You should be able to create a (very, very!) minimal HTML twig by using my $html= XML::Twig->new->parse_html( '') and then paste your div in it. You may want to`replace the empty string by something a little more HTML-y though, or even load a better HTML template, which could have the CSS in it too.
I am new to GWT and I need to add a big piece of html code (contains a lot of included divs with id and classes) to the html-panel widget in my java file.
I have tried to add like this:
HTML html = new HTML("<div class=\"class1\">This is a class1.");
HTML html2 = new HTML("And it ends here</p>");
RootPanel.get().add(html);
RootPanel.get().add(html2);
But I have a problem with included divs. Is there any simpler way to this big piece of code. Thanks.
You, sir, are looking for UiBinder:
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder
UiBinder is great when you are doing a lot in plain HTML.
However, UiBinder offers a lot once you get in deep so be careful. I recommend looking into CssResource and how it releates to UiBinder so you can share some Css or just embed Css in each UiBinder file. (Note programatic access to Css within UiBinder files)
Also not other features such as importing other custom UiBinder/Widgets with namespaces such as the built in (< g:Button> -> < mynamespace:MyCustomWidget>)
But you are probably just looking for laying everything out in UiBinder and defining the #UiField's in the java file
Hope this helps!
-Ashton
If your HTML is static, you must use UiBinder.
If your HTML is generated dynamically, you can use com.google.gwt.user.client.ui.HTML.
Your code is not working because you must give to the HTML constructor a valid html string.
I suggest you to read this guide:
https://developers.google.com/web-toolkit/doc/latest/DevGuideSecuritySafeHtml#Prefer_Plain_Text.
I am trying to load and parse html in adobe air. The main purpose being to extract title, meta tags and links. I have been trying the HTMLLoader but I get all sort of errors, mainly javascript uncaught exceptions.
I also tried to load the html content directly (using URLLoader) and push the text into HTMLLoader (using loadString(...)) but got the same error. Last resort was to try and load the text into xml and then use E4X queries or xpath, no luck there cause the html is not well formed.
My questions are:
Is there simple and reliable (air/action script) DOM component there (I do not need to display the page and headless mode will do)?
Is there any library to convert (crappy) html into well formed xml so I can use xpath/E4X
Any other suggestions on how to do this?
thx
ActionScript is supposed to be a superset of JavaScript, and thankfully, there's...
Pure JavaScript/ActionScript HTML Parser
created by Javascript guru and jQuery creator John Resig :-)
One approach is to run the HTML through HTMLtoXML() then use E4X as you please :)
Afaik:
No :-(
No :-(
I think the easiest way to grab title and meta tags is writing some regular expressions. You can load the page's HTML code into a string and then read out whatever you need like this:
var str:String = ""; // put HTML code in here
var pattern:RegExp = /<title>(.+)<\/title>/i;
trace(pattern.exec(str));