in reply to Conditional regex
I am parsing a webpage right now to make it 508 compliant.
Doesn't your parser have a means of locating IMG elements, and for each of them add an attributes if the attribute doesn't already exist? Looks like 3-4 lines of code.
Update: For XML::LibXML, it would be something similar to the following snippets. I expect something similar from HTML parsers.
or evenfor my $ele ($doc->findnodes('//img')) { if (!defined($ele->getAttribute('alt'))) { $ele->setAttribute(alt => ...); } }
for my $ele ($doc->findnodes('//img[count(@alt)==0]')) { $ele->setAttribute(alt => ...); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Conditional regex
by sherab (Scribe) on May 08, 2009 at 20:22 UTC | |
by ikegami (Patriarch) on May 08, 2009 at 20:27 UTC | |
by Your Mother (Archbishop) on May 08, 2009 at 20:26 UTC |