Re: Extracting attributes of DOM elements
Sandy Pérez González <[email protected]> Wed, 13 Jun 2007 15:12:08 +0200
| Newsgroups | gmane.comp.mozilla.jrex |
|---|---|
| Organization | Onekin |
| Message-ID | <[email protected]> |
--===============0300233164==
Content-Type: multipart/signed; protocol="application/pgp-signature";
micalg="pgp-sha1"; boundary="----------8E15C1551C3983B7"
------------8E15C1551C3983B7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Hello,
You can try something like this:
public static Map getStyleAttributeItems(HTMLElement element) {
Map result =3D new HashMap();
String styleAttr =3D element.getAttribute("style");
if ((styleAttr !=3D null) && (styleAttr.length() > 0)) {
StringTokenizer itemTokenizer =3D new StringTokenizer(styleAttr=
, ";");
while (itemTokenizer.hasMoreTokens()) {
String item =3D itemTokenizer.nextToken().trim();
if (item.length() > 0) {
int colonPos =3D item.indexOf(':');
String itemName =3D (colonPos < 0 ? item : item.substr=
ing(0, colonPos).trim());
String itemValue =3D (colonPos < 0 ? "" : item.substrin=
g(colonPos + 1).trim());
result.put(itemName, itemValue);
}
}
}
return result;
}
****Code extracted from the Floyd project https://floyd.dev.java.net/
=20
--=20
Regards,
Sandy
> Hi,
> We would like to get attributes of elements in DOM, like style of=
the
> element, whether it is written by bold, italics, getting its font, color,
> etc. These attributes can be expressed by tag, in the css stylesheet ... =
Does
> any method exist for computing these attributes from JRex DOM?
> Thanks for your help,
> Gyuri Frivolt
------------8E15C1551C3983B7
Content-Type: application/pgp-signature
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.5 (MingW32)
iQEVAwUBRm/tKOlQ3ZWsXCevAQKKIggAmqhpqxSyy/zcFy3wATLpnpQBy1oCU7fw
4BWy9ghU2u9CVGkfRoHWpXXXygUvAOBKmwAFSUc2leV0TjB4/QLQJNFbzaIXCSzZ
b6RWRgf1bJ+ADVpewPe6Ga/lpWOoRIB3CfNtmk3YK9NXc7WxanB+62RQ9bAza470
K+vr8jSZZueV6MIHUMLldjxyQWoNFNJT2qRqzwVxY9DyNyzm1ufUF6VVf28h2FSr
ZrXVpnWw+dr8EN23Vbdg+60pbwZhFVqLyl2jdXoWghAOUeeNQMh04mqWa2QnQ5rr
J5oAoLiVRGps1EM8xKYKjQ2pOBk1Sr3fLcgdLm0NLhjWvFFrlXpkdw==
=e82a
-----END PGP MESSAGE-----
------------8E15C1551C3983B7--
--===============0300233164==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
JRex mailing list
[email protected]
http://mozdev.org/mailman/listinfo/jrex
--===============0300233164==--