views:

55

answers:

1

HI all,,

I want to edit a html at run time ---- what i want to do is i have a html file on the server and i pass its tags in the other language as like this

NSString* contentHTML = [NSString stringWithFormat:@"<html><head></head><body><b><font face='arial' size='%d' color='%@'>%@</font></b></body></html>",[appDelegate.sTextFont integerValue], appDelegate.sTextColor, aStr];

and when html comes than it follow the upper code for the text and font and it gets changed as my need,

But what i want to do is i want to pass the img src ="myserverurl" and it just append to the argument passed in the src tag and than it becomes like this .

is it possible to append the string like this in any tag in the html and by the way can we append the string in the html tag .

Thanks

+2  A: 

Working with the HTML as an string makes it really hard to insert and modify attributes on tags.

Parse the HTML and manipulate it as XML DOM. The XML DOM contains methods to traverse XML trees, access, insert, and delete nodes.

I'd get the code working using this approach first - then sort out the performance problems later by refactoring the code by being sneaky. First get the code working then smart and fast

Niels Castle