Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given array of characters * </p> * * @param text * is the text to parse * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(char[] text) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(text); return parseDocument(); }
private Packet setHttpFieldProperties(XmlStartTag st, Packet currentPacket) throws XmlPullParserException { parser.readStartTag(st); XmlAttributesHashMap<String, String> attributes = new XmlAttributesHashMap<>(); for (int i = 0; i < st.getAttributeCount(); i++) { attributes.put(st.getAttributeLocalName(i).trim(), st.getAttributeValue(i).trim()); } // used for id if ( attributes.checkIfEqual("name", "http.request.method") ) { currentPacket.setHttpRequestType(Packet.RequestType.valueOf(attributes.get("show"))); } else if ( attributes.checkIfEqual("name", "http.request.uri") ) { currentPacket.setHttpRequestURI(attributes.get("show")); } // used for formatting of payload if(fieldStack.size() == 1){ String pos = attributes.get("pos"); String size = attributes.get("size"); // Some fields don't have pos and size, e.g. data field in http proto packet if (pos != null && size != null) { currentPacket.addHttpField(attributes.get("name"), attributes.get("show"), Integer.parseInt(pos) - currentPacket.getTcpPayloadStart(), Integer.parseInt(size)); } } return currentPacket; }
fieldStack.empty(); try { eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: if ( parser.getRawName().contains("packet") ) { // At packet tag currentPacket = setPacketProperties(xppFactory.newStartTag()); else if ( parser.getRawName().contains("proto") ) { currentPacket = setProtoProperties(xppFactory.newStartTag(), currentPacket); else if ( parser.getRawName().contains("field") ) { fieldStack.push("field"); if ( parser.getRawName().contains("packet") ) { eventType = parser.next(); return currentPacket; else if ( parser.getRawName().contains("proto") ) { protoStack.pop(); else if ( parser.getRawName().contains("field") ) { fieldStack.pop(); eventType = parser.next();
private Packet setProtoProperties(XmlStartTag st, Packet currentPacket) throws XmlPullParserException { parser.readStartTag(st); XmlAttributesHashMap<String, String> attributes = new XmlAttributesHashMap<>(); for (int i = 0; i < st.getAttributeCount(); i++) { attributes.put(st.getAttributeLocalName(i).trim(), st.getAttributeValue(i).trim()); } protoStack.push(attributes.get("name")); //tcp if ( attributes.checkIfEqual("name", "geninfo") ) { currentPacket.setPacketSize(Integer.parseInt(attributes.get("size"))); } //geninfo else if ( attributes.checkIfEqual("name", "tcp") ) { currentPacket.setTcp(true); currentPacket.setTcpPayloadStart(Integer.parseInt(attributes.get("pos")) + (Integer.parseInt(attributes.get("size")))); } else if ( attributes.checkIfEqual("name", "fake-field-wrapper") ) { currentPacket.setFragmented(true); } else if ( attributes.checkIfEqual("name", "http")){ // don't set http if this packet is the last fragment of a fragmented HTTP request/response // because we have no logic to reassemble the packet content, and anyway we want the script // to maintain the original (fragmented) nature of the traffic if (!currentPacket.isFragmented()) { currentPacket.setHttp(true); } } return currentPacket; }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
private Packet setFieldProperties(XmlStartTag st, Packet currentPacket) throws XmlPullParserException { parser.readStartTag(st); XmlAttributesHashMap<String, String> attributes = new XmlAttributesHashMap<>(); for (int i = 0; i < st.getAttributeCount(); i++) {
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given array of characters * </p> * * @param text * is the text to parse * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(char[] text) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(text); return parseDocument(); }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
Element parent = null; XmlPullParser parser = getXPPParser(); parser.setNamespaceAware(true); int type = parser.next(); parser.readStartTag(startTag); parser.readEndTag(endTag); String text = parser.readContent();
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }