本文整理汇总了C#中org.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# org.getAttributeValue方法的具体用法?C# org.getAttributeValue怎么用?C# org.getAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.getAttributeValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readThisValueXml
/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
/// <exception cref="System.IO.IOException"></exception>
private static object readThisValueXml(org.xmlpull.v1.XmlPullParser parser, string
[] name)
{
string valueName = parser.getAttributeValue(null, "name");
string tagName = parser.getName();
//System.out.println("Reading this value tag: " + tagName + ", name=" + valueName);
object res;
if (tagName.Equals("null"))
{
res = null;
}
else
{
if (tagName.Equals("string"))
{
string value = string.Empty;
int eventType;
while ((eventType = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT
)
{
if (eventType == org.xmlpull.v1.XmlPullParserClass.END_TAG)
{
if (parser.getName().Equals("string"))
{
name[0] = valueName;
//System.out.println("Returning value for " + valueName + ": " + value);
return value;
}
throw new org.xmlpull.v1.XmlPullParserException("Unexpected end tag in <string>: "
+ parser.getName());
}
else
{
if (eventType == org.xmlpull.v1.XmlPullParserClass.TEXT)
{
value += parser.getText();
}
else
{
if (eventType == org.xmlpull.v1.XmlPullParserClass.START_TAG)
{
throw new org.xmlpull.v1.XmlPullParserException("Unexpected start tag in <string>: "
+ parser.getName());
}
}
}
}
throw new org.xmlpull.v1.XmlPullParserException("Unexpected end of document in <string>"
);
}
else
{
if (tagName.Equals("int"))
{
res = System.Convert.ToInt32(parser.getAttributeValue(null, "value"));
}
else
{
if (tagName.Equals("long"))
{
res = long.Parse(parser.getAttributeValue(null, "value"));
}
else
{
if (tagName.Equals("float"))
{
res = System.Convert.ToSingle(parser.getAttributeValue(null, "value"));
}
else
{
if (tagName.Equals("double"))
{
res = System.Convert.ToDouble(parser.getAttributeValue(null, "value"));
}
else
{
if (tagName.Equals("boolean"))
{
res = bool.Parse(parser.getAttributeValue(null, "value"));
}
else
{
if (tagName.Equals("int-array"))
{
parser.next();
res = readThisIntArrayXml(parser, "int-array", name);
name[0] = valueName;
//System.out.println("Returning value for " + valueName + ": " + res);
return res;
}
else
{
if (tagName.Equals("map"))
{
parser.next();
res = readThisMapXml(parser, "map", name);
name[0] = valueName;
//System.out.println("Returning value for " + valueName + ": " + res);
//.........这里部分代码省略.........
示例2: readThisIntArrayXml
/// <summary>Read an int[] object from an XmlPullParser.</summary>
/// <remarks>
/// Read an int[] object from an XmlPullParser. The XML data could
/// previously have been generated by writeIntArrayXml(). The XmlPullParser
/// must be positioned <em>after</em> the tag that begins the list.
/// </remarks>
/// <param name="parser">The XmlPullParser from which to read the list data.</param>
/// <param name="endTag">Name of the tag that will end the list, usually "list".</param>
/// <param name="name">
/// An array of one string, used to return the name attribute
/// of the list's tag.
/// </param>
/// <returns>Returns a newly generated int[].</returns>
/// <seealso cref="readListXml(java.io.InputStream)">readListXml(java.io.InputStream)
/// </seealso>
/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
/// <exception cref="System.IO.IOException"></exception>
public static int[] readThisIntArrayXml(org.xmlpull.v1.XmlPullParser parser, string
endTag, string[] name)
{
int num;
try
{
num = System.Convert.ToInt32(parser.getAttributeValue(null, "num"));
}
catch (System.ArgumentNullException)
{
throw new org.xmlpull.v1.XmlPullParserException("Need num attribute in byte-array"
);
}
catch (System.ArgumentException)
{
throw new org.xmlpull.v1.XmlPullParserException("Not a number in num attribute in byte-array"
);
}
int[] array = new int[num];
int i = 0;
int eventType = parser.getEventType();
do
{
if (eventType == org.xmlpull.v1.XmlPullParserClass.START_TAG)
{
if (parser.getName().Equals("item"))
{
try
{
array[i] = System.Convert.ToInt32(parser.getAttributeValue(null, "value"));
}
catch (System.ArgumentNullException)
{
throw new org.xmlpull.v1.XmlPullParserException("Need value attribute in item");
}
catch (System.ArgumentException)
{
throw new org.xmlpull.v1.XmlPullParserException("Not a number in value attribute in item"
);
}
}
else
{
throw new org.xmlpull.v1.XmlPullParserException("Expected item tag at: " + parser
.getName());
}
}
else
{
if (eventType == org.xmlpull.v1.XmlPullParserClass.END_TAG)
{
if (parser.getName().Equals(endTag))
{
return array;
}
else
{
if (parser.getName().Equals("item"))
{
i++;
}
else
{
throw new org.xmlpull.v1.XmlPullParserException("Expected " + endTag + " end tag at: "
+ parser.getName());
}
}
}
}
eventType = parser.next();
}
while (eventType != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT);
throw new org.xmlpull.v1.XmlPullParserException("Document ended before " + endTag
+ " end tag");
}