本文整理匯總了Java中org.xmlpull.v1.XmlPullParserFactory.setValidating方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParserFactory.setValidating方法的具體用法?Java XmlPullParserFactory.setValidating怎麽用?Java XmlPullParserFactory.setValidating使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xmlpull.v1.XmlPullParserFactory
的用法示例。
在下文中一共展示了XmlPullParserFactory.setValidating方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
Podcasts parse(InputStream input, @Nullable String charset, String baseUri) throws IOException {
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(input, charset);
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
String tag = xpp.getName();
if (LayoutUtils.isDiv(tag) && hasClass(xpp, PODCAST_LIST_CLASS)) {
return parsePodcasts(xpp, NetworkUtils.toOptURI(baseUri));
}
}
eventType = lenientNext(xpp);
}
return new Podcasts();
} catch (XmlPullParserException e) {
throw new IOException(e);
}
}
示例2: getXmlPullParser
import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
* Gets a XmlPullParser for use in parsing incoming messages.
*
* @return parser instance
*/
private static XmlPullParser getXmlPullParser() {
SoftReference<XmlPullParser> ref = XPP_PARSER.get();
XmlPullParser result = ref.get();
if (result == null) {
Exception thrown;
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
result = factory.newPullParser();
ref = new SoftReference<XmlPullParser>(result);
XPP_PARSER.set(ref);
return result;
} catch (Exception ex) {
thrown = ex;
}
throw(new IllegalStateException(
"Could not create XmlPull parser", thrown));
} else {
return result;
}
}
示例3: DisplayLayout
import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public DisplayLayout(Context context, AttributeSet attrs) {
super(context, attrs);
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setValidating(false);
} catch (XmlPullParserException e) {
Log.e(TAG, "Error creating XmlPullParserFactory", e);
}
TypedArray ta = context.obtainStyledAttributes(
attrs,
R.styleable.DisplayLayout
);
String presentationName = AppState.getInstance().getPresentationName();
if (presentationName != null) {
Log.v(TAG, "Presentation: " + presentationName);
int id = getResources().getIdentifier(presentationName, "array", context.getPackageName());
Log.v(TAG, "id: " + id);
if (id > 0) {
String[] slideNames = getResources().getStringArray(id);
Log.v(TAG, "slideNames: " + Arrays.toString(slideNames));
slides.addAll(Arrays.asList(slideNames));
}
for (String slide : slides) {
Log.v(TAG, "Slide: " + slide);
}
}
inAnim = ta.getResourceId(R.styleable.DisplayLayout_inAnimation, -1);
outAnim = ta.getResourceId(R.styleable.DisplayLayout_outAnimation, -1);
ta.recycle();
}
示例4: getAttrs
import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static AttributeSet getAttrs(InputStream inputStream, String tagName, Map<String, String> customAttrs) {
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setValidating(true);
XmlPullParser parser = factory.newPullParser();
parser.setInput(inputStream, "UTF-8");
return getAttrs(parser, tagName, customAttrs);
} catch (XmlPullParserException e) {
e.printStackTrace();
}
return null;
}
示例5: createXmlSerializer
import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static XmlSerializer createXmlSerializer(Writer out) {
XmlSerializer result = null;
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setValidating(true);
result = factory.newSerializer();
result.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
result.setOutput(out);
} catch (Exception e) {
log.error("When creating XmlSerializer: " + e.getClass().getName() + ": " + e.getMessage());
}
return result;
}