I want to transform this sample tag <input name="pippo" type=text> to <input name="pippo" type="text">
quoting every attribute in it (if not already quoted).
I tryed using this code Iterator ai = tag.getAttributesEx().iterator(); ai.next(); // skip first attribute (the tag name) while (ai.hasNext()) {
Attribute a = (Attribute)ai.next(); a.setQuote('"'); } but this is what I obtain <input" "name="pippo"" "type="text">
there is an error in my code? thanks
You are quoting the whitespace too. Try: if (!a.isWhiteSpace ()) a.setQuote('"');
perfect it works!
very very thanks
Log in to post a comment.
I want to transform this sample tag
<input name="pippo" type=text>
to
<input name="pippo" type="text">
quoting every attribute in it (if not already quoted).
I tryed using this code
Iterator ai = tag.getAttributesEx().iterator();
ai.next(); // skip first attribute (the tag name)
while (ai.hasNext())
{
Attribute a = (Attribute)ai.next();
a.setQuote('"');
}
but this is what I obtain
<input" "name="pippo"" "type="text">
there is an error in my code?
thanks
You are quoting the whitespace too.
Try:
if (!a.isWhiteSpace ())
a.setQuote('"');
perfect
it works!
very very thanks