List of usage examples for org.xml.sax Attributes getLocalName
public abstract String getLocalName(int index);
From source file:SAXTest.java
public static void main(String[] args) throws Exception { String url;//ww w . jav a2 s.co m if (args.length == 0) { url = "http://www.w3c.org"; System.out.println("Using " + url); } else url = args[0]; DefaultHandler handler = new DefaultHandler() { public void startElement(String namespaceURI, String lname, String qname, Attributes attrs) { if (lname.equals("a") && attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String aname = attrs.getLocalName(i); if (aname.equals("href")) System.out.println(attrs.getValue(i)); } } } }; SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); SAXParser saxParser = factory.newSAXParser(); InputStream in = new URL(url).openStream(); saxParser.parse(in, handler); }
From source file:Main.java
public static Map<String, String> attributeToStringMap(Attributes attrs) { Map<String, String> data = new HashMap<String, String>(); for (int i = 0; i < attrs.getLength(); i++) { data.put(attrs.getLocalName(i), attrs.getValue(i).trim()); }/*from ww w .j a va2 s. c o m*/ return data; }
From source file:com.bellman.bible.service.format.osistohtml.taghandler.TagHandlerHelper.java
public static void printAttributes(Attributes attrs) { for (int i = 0; i < attrs.getLength(); i++) { log.debug(attrs.getLocalName(i) + ":" + attrs.getValue(i)); }/*from w ww . jav a2s. c om*/ }
From source file:Main.java
public static void DoConvertAttrsToStringMap(Attributes atts, HashMap<String, String> MapDest) { for (int attrsIndex = 0; attrsIndex < atts.getLength(); attrsIndex++) { String AttrName = atts.getLocalName(attrsIndex); String AttrValue = atts.getValue(attrsIndex); try {/*from ww w. j a v a2 s. co m*/ AttrValue = URLDecoder.decode(AttrValue, URL_DECODE_TYPE); MapDest.put(AttrName, AttrValue); } catch (UnsupportedEncodingException e) { // TODO } //Log.w("FCXML", "DoConvertAttrsToStringMap: Index: " + attrsIndex + " Name: " + AttrName + " Value " + AttrValue ); } }
From source file:io.wcm.handler.url.rewriter.impl.ComparableAttributes.java
static String serializedString(Attributes attributes) { StringBuilder serialized = new StringBuilder(); for (int i = 0; i < attributes.getLength(); i++) { serialized.append(attributes.getLocalName(i)).append("=").append(attributes.getValue(i)).append(";"); }/*w ww. j a v a 2 s .c om*/ return serialized.toString(); }
From source file:com.day.cq.wcm.foundation.TableXMLBuilder.java
private static void addAttributes(Table.Cell cell, Attributes attrs) { for (int i = 0; i < attrs.getLength(); i++) { String name = attrs.getLocalName(i); if (!name.equals("quotes")) { String value = attrs.getValue(i); cell.setAttribute(name, value); }//from ww w. j ava 2 s . c o m } }
From source file:com.day.cq.wcm.foundation.TableXMLBuilder.java
private static void addAttributes(Table.Tag tag, Attributes attrs) { for (int i = 0; i < attrs.getLength(); i++) { String name = attrs.getLocalName(i); if (!name.equals("quotes")) { String value = attrs.getValue(i); tag.setAttribute(name, value); }/*from www.j a v a2 s. c o m*/ } }
From source file:com.day.cq.wcm.foundation.TableXMLBuilder.java
private static void addAttributes(Table tag, Attributes attrs) { for (int i = 0; i < attrs.getLength(); i++) { String name = attrs.getLocalName(i); if (!name.equals("quotes")) { String value = attrs.getValue(i); tag.setAttribute(name, value); }/*from ww w.jav a 2 s . c o m*/ } }
From source file:Main.java
public static Map<String, String> convertSAXAttributes(Attributes attributes, boolean useQualifiedName) { Map<String, String> map = newAttributes(); for (int i = 0; i < attributes.getLength(); i++) { String key = useQualifiedName ? attributes.getQName(i) : attributes.getLocalName(i); String value = attributes.getValue(i); map.put(key, value);/*www .j a va 2 s . c o m*/ } return map; }
From source file:Main.java
public static String attributesToString(Attributes attributes) { // (use StringBuffer for J2SE 1.4 compatibility) StringBuffer buffer = new StringBuffer(); for (int loop = 0, length = attributes.getLength(); loop < length; loop++) { buffer.append(" "); buffer.append(attributes.getLocalName(loop)); buffer.append("=\""); buffer.append(attributes.getValue(loop)); buffer.append("\""); }/*from w ww . j a va 2s . co m*/ return buffer.toString(); }