本文整理汇总了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;
}