NSXMLParser - modify the elements in iPhone

2019-08-12 15:30发布

问题:

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.

回答1:

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