Menu

quoting any attribute

Help
maxcube
2005-09-08
2013-04-27
  • maxcube

    maxcube - 2005-09-08

    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

     
    • Derrick Oswald

      Derrick Oswald - 2005-09-09

      You are quoting the whitespace too.
      Try:
        if (!a.isWhiteSpace ())
           a.setQuote('"');

       
    • maxcube

      maxcube - 2005-09-12

      perfect
      it works!

      very very thanks

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.