Share via


IXmlPullParser.GetNamespaceCount(Int32) Method

Definition

Returns the numbers of elements in the namespace stack for the given depth.

[Android.Runtime.Register("getNamespaceCount", "(I)I", "GetGetNamespaceCount_IHandler:Org.XmlPull.V1.IXmlPullParserInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public int GetNamespaceCount (int depth);
[<Android.Runtime.Register("getNamespaceCount", "(I)I", "GetGetNamespaceCount_IHandler:Org.XmlPull.V1.IXmlPullParserInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member GetNamespaceCount : int -> int

Parameters

depth
Int32

Returns

Attributes

Exceptions

Remarks

Returns the numbers of elements in the namespace stack for the given depth. If namespaces are not enabled, 0 is returned.

<b>NOTE:</b> when parser is on END_TAG then it is allowed to call this function with getDepth()+1 argument to retrieve position of namespace prefixes and URIs that were declared on corresponding START_TAG.

<b>NOTE:</b> to retrieve list of namespaces declared in current element:

XmlPullParser pp = ...
                  int nsStart = pp.getNamespaceCount(pp.getDepth()-1);
                  int nsEnd = pp.getNamespaceCount(pp.getDepth());
                  for (int i = nsStart; i < nsEnd; i++) {
                     String prefix = pp.getNamespacePrefix(i);
                     String ns = pp.getNamespaceUri(i);
                      // ...
                 }

Java documentation for org.xmlpull.v1.XmlPullParser.getNamespaceCount(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to