Here you can find the source of getXmlBetweenTag(String xml, String tag)
Parameter | Description |
---|---|
xml | the origin response return from ONVIF device |
tag | tag name of destination border |
public static String getXmlBetweenTag(String xml, String tag)
//package com.java2s; import android.util.Log; public class Main { private static final String TAG = "XstreamUtil"; /**//from www . j av a 2 s . c om * @param xml the origin response return from ONVIF device * @param tag tag name of destination border * @return the content between tag */ public static String getXmlBetweenTag(String xml, String tag) { if (xml == null) { Log.e(TAG, "getXmlBetweenTag, params xml:" + xml + ", tag:" + tag); return ""; } String ret = ""; String start = "<" + tag + ">"; String end = "</" + tag + ">"; int startIndex = xml.indexOf(start) + start.length(); int endIndex = xml.indexOf(end); Log.i(TAG, "getXmlBetweenTag, startIndex:" + startIndex + ", endIndex:" + endIndex); if (startIndex > 0 && endIndex > startIndex) { ret = xml.substring(startIndex, endIndex); } //Log.i(TAG, "getXmlBetweenTag, ret:" + ret); return ret; } }