本文整理汇总了C#中XmlReader.MoveToNextAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.MoveToNextAttribute方法的具体用法?C# XmlReader.MoveToNextAttribute怎么用?C# XmlReader.MoveToNextAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.MoveToNextAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
string last_element = "";
int counter = 1;
textAsset = (TextAsset) Resources.Load("XMLs/tea_dialog");
reader = XmlReader.Create(new StringReader(textAsset.text));
//pull in the animation names from the xml file
while (reader.Read ()) {
if(reader.NodeType == XmlNodeType.Element){
while(reader.MoveToNextAttribute())
{
if(reader.Name == "id")
{
//print (counter + " : " + reader.Value);
animIndices.Add (counter, reader.Value);
counter += 1;
}
}
}
}
//print out hash table, for testing purposes
//printHashTable ();
}
示例2: DumpReader
public void DumpReader (XmlReader xr, bool attValue)
{
Console.WriteLine ("NodeType: " + xr.NodeType);
Console.WriteLine ("Prefix: " + xr.Prefix);
Console.WriteLine ("Name: " + xr.Name);
Console.WriteLine ("LocalName: " + xr.LocalName);
Console.WriteLine ("NamespaceURI: " + xr.NamespaceURI);
Console.WriteLine ("Value: " + xr.Value);
Console.WriteLine ("Depth: " + xr.Depth);
Console.WriteLine ("IsEmptyElement: " + xr.IsEmptyElement);
if (xr.NodeType == XmlNodeType.Attribute) {
Console.WriteLine ("Attribute Values::::");
while (xr.ReadAttributeValue ())
DumpReader (xr, true);
Console.WriteLine (":::Attribute Values End");
} else if (!attValue) {
Console.WriteLine ("Attributes::::");
Console.Write (xr.AttributeCount);
if (xr.MoveToFirstAttribute ()) {
do {
DumpReader (xr, false);
} while (xr.MoveToNextAttribute ());
xr.MoveToElement ();
}
Console.WriteLine (":::Attributes End");
}
}
示例3: ReadData
/// <summary>
/// Reads a specific data tag from the xml document.
/// </summary>
/// <param name='reader'>
/// Reader.
/// </param>
private void ReadData(XmlReader reader)
{
//If these values are not being set,
//something is wrong.
string key = "ERROR";
string value = "ERROR";
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
if (reader.Name == "name")
{
key = reader.Value;
}
}
}
//Move back to the element
reader.MoveToElement();
//Read the child nodes
if (reader.ReadToDescendant("value"))
{
do
{
value = reader.ReadString();
}
while (reader.ReadToNextSibling("value"));
}
//Add the raw values to the dictionary
textDataBase.Add(key, value);
//Add the localized parsed values to the localizedObjectDataBase
LocalizedObject newLocalizedObject = new LocalizedObject();
newLocalizedObject.ObjectType = LocalizedObject.GetLocalizedObjectType(key);
newLocalizedObject.TextValue = value;
localizedObjectDataBase.Add(LocalizedObject.GetCleanKey(key,newLocalizedObject.ObjectType), newLocalizedObject);
}
示例4: check_attribute_group
// Read and extract into InterfaceRight class each attribut of node name "group"
InterfaceElement check_attribute_group(XmlReader xml_reader)
{
InterfaceElement s_InterfaceElement = new InterfaceElement();
s_InterfaceElement.mse_type = 0;
s_InterfaceElement.b_toggle_type = false;
s_InterfaceElement.s_content = "undefined";
s_InterfaceElement.s_text_area = "Choose a title";
if (xml_reader.HasAttributes)
{
while (xml_reader.MoveToNextAttribute() != false)
{
bool valide_type = true;
string save_type = "";
string save_readstring = "";
string save_content = "";
// if type exist, else, a button will be created
if ((save_type = xml_reader.GetAttribute("type")) != null)
{
if (Enum.IsDefined(typeof(me_button_type),save_type) == true)
s_InterfaceElement.mse_type = (me_button_type)Enum.Parse(typeof(me_button_type), save_type);
else
valide_type = false;
}
// if content as attribute or string exist, else, "undefined" has been saved
if ((save_content = xml_reader.GetAttribute("content")) != null || (save_readstring = xml_reader.ReadString()) != null)
{
s_InterfaceElement.s_content = save_content != null ? save_content : save_readstring;
if (valide_type == false)
s_InterfaceElement.s_content += " (Coming Soon)";
}
}
}
return s_InterfaceElement;
}
示例5: check_attribute_element
// Read and extract into Element class each attribut of node name "element"
Element check_attribute_element(XmlReader xml_reader, Element element)
{
if (xml_reader.HasAttributes)
{
while (xml_reader.MoveToNextAttribute() != false)
{
string prefab_name = "";
if ((prefab_name = xml_reader.GetAttribute("prefab")) != null)
{
if (Resources.Load(prefab_name) != null)
element.prefab = Resources.Load(prefab_name) as GameObject;
}
}
}
return element;
}
示例6: ReadContentFrom
internal void ReadContentFrom(XmlReader r, LoadOptions o)
{
if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
{
ReadContentFrom(r);
return;
}
if (r.ReadState != ReadState.Interactive) throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
XContainer c = this;
XNode n = null;
NamespaceCache eCache = new NamespaceCache();
NamespaceCache aCache = new NamespaceCache();
string baseUri = (o & LoadOptions.SetBaseUri) != 0 ? r.BaseURI : null;
IXmlLineInfo li = (o & LoadOptions.SetLineInfo) != 0 ? r as IXmlLineInfo : null;
do
{
string uri = r.BaseURI;
switch (r.NodeType)
{
case XmlNodeType.Element:
{
XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
if (baseUri != null && baseUri != uri)
{
e.SetBaseUri(uri);
}
if (li != null && li.HasLineInfo())
{
e.SetLineInfo(li.LineNumber, li.LinePosition);
}
if (r.MoveToFirstAttribute())
{
do
{
XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
if (li != null && li.HasLineInfo())
{
a.SetLineInfo(li.LineNumber, li.LinePosition);
}
e.AppendAttributeSkipNotify(a);
} while (r.MoveToNextAttribute());
r.MoveToElement();
}
c.AddNodeSkipNotify(e);
if (!r.IsEmptyElement)
{
c = e;
if (baseUri != null)
{
baseUri = uri;
}
}
break;
}
case XmlNodeType.EndElement:
{
if (c.content == null)
{
c.content = string.Empty;
}
// Store the line info of the end element tag.
// Note that since we've got EndElement the current container must be an XElement
XElement e = c as XElement;
Debug.Assert(e != null, "EndElement received but the current container is not an element.");
if (e != null && li != null && li.HasLineInfo())
{
e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
}
if (c == this) return;
if (baseUri != null && c.HasBaseUri)
{
baseUri = c.parent.BaseUri;
}
c = c.parent;
break;
}
case XmlNodeType.Text:
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Whitespace:
if ((baseUri != null && baseUri != uri) ||
(li != null && li.HasLineInfo()))
{
n = new XText(r.Value);
}
else
{
c.AddStringSkipNotify(r.Value);
}
break;
case XmlNodeType.CDATA:
n = new XCData(r.Value);
break;
case XmlNodeType.Comment:
n = new XComment(r.Value);
break;
case XmlNodeType.ProcessingInstruction:
n = new XProcessingInstruction(r.Name, r.Value);
break;
case XmlNodeType.DocumentType:
n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
//.........这里部分代码省略.........
示例7: findAllLinks
/// <summary>
/// Find all links.
/// </summary>
private IEnumerable<string> findAllLinks(
XmlReader xml,
string baseUrl )
{
var links = new List<string>();
while ( xml.Read() )
{
switch ( xml.NodeType )
{
// Added 2006-03-27: Inside comments, too.
case XmlNodeType.Comment:
XmlReader childXml = getDocReader( xml.Value, baseUrl );
IEnumerable<string> childLinks = findAllLinks( childXml, baseUrl );
links.AddRange( childLinks );
break;
// A node element.
case XmlNodeType.Element:
string[] linkAttributeNames;
// If this is a link element, store the URLs to modify.
if ( isLinkElement( xml.Name, out linkAttributeNames ) )
{
while ( xml.MoveToNextAttribute() )
{
checkAddStyleAttributeLinks(
xml.Name,
xml.Value,
links );
// ReSharper disable LoopCanBeConvertedToQuery
foreach ( string a in linkAttributeNames )
// ReSharper restore LoopCanBeConvertedToQuery
{
if ( a.ToLower() == xml.Name.ToLower() )
{
string linkUrl = xml.Value;
if ( !isAbsoluteUrl( linkUrl ) )
{
links.Add( linkUrl );
}
}
}
}
}
else
{
// Also, look for style attributes.
while ( xml.MoveToNextAttribute() )
{
checkAddStyleAttributeLinks(
xml.Name,
xml.Value,
links );
}
}
break;
}
}
return links.ToArray();
}
示例8: OutputXml
} //ReadTransformWrite()
/// <summary>
/// Output the tranformed XML in annotated form to the console.
/// Calls the Output method.
/// </summary>
/// <param name="reader"></param>
private static void OutputXml (XmlReader reader)
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Output(reader, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Output(reader, "DocumentType");
break;
case XmlNodeType.Document:
Output(reader, "Document");
break;
case XmlNodeType.Comment:
Output(reader, "Comment");
break;
case XmlNodeType.Element:
Output(reader, "Element");
while(reader.MoveToNextAttribute())
{
Output(reader, "Attribute");
} //while
break;
case XmlNodeType.Text:
Boolean flag = false;
// Do not display whitespace text nodes
for (int i=0; i < reader.Value.Length; i++)
{
if (!System.Char.IsWhiteSpace(reader.Value[i]))
flag = true;
} //for
if(flag)
Output (reader, "Text");
break;
} //switch
} //while
Console.WriteLine();
} //OutputXML()
示例9: ExtractClientConfig
/* Method to extract the client specific parts of the config file */
private bool ExtractClientConfig(XmlReader reader)
{
try {
while (reader.Read()) {
if (reader.IsStartElement()) {
if (reader.Name == "client") {
client_config.Add(new ClientConfig());
while (reader.MoveToNextAttribute()) {
if (reader.Name == "name")
client_config.Last().name.Add("short_name", reader.Value);
else if (reader.Name == "lname")
client_config.Last().name.Add("full_name", reader.Value);
else
Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
}
}
else if (reader.Name == "project")
client_config.Last().projects.Add(reader.ReadString());
else if (reader.Name == "priority")
client_config.Last().priority.Add(reader.ReadString());
else if (reader.Name == "email")
client_config.Last().email.Add(reader.ReadString());
}
}
return true;
}
catch (Exception ex) {
Console.WriteLine("Exception when extracting client data from config XML: " + ex.Message);
return false;
}
}
示例10: ExtractAttributes
/// PRIVATE METHODS ///
///
/* Method which extracts the attributes from an XML node.
* All attributes in the XML file are declared here. Each
* should have a unique name. It would be possible to allow
* node scoped attributes by adding extra parameters. Might
* do this in the future if need this method to do it. */
private bool ExtractAttributes(XmlReader reader)
{
if (reader.HasAttributes) {
while (reader.MoveToNextAttribute()) {
// Console.WriteLine(reader.Name);
switch (reader.Name) {
/* Jira Config variables */
case "host":
jira_config.data.Add("host", reader.Value);
break;
case "user":
jira_config.data.Add("user", reader.Value);
break;
case "pass":
jira_config.data.Add("pass", reader.Value);
break;
/* File Config variables */
case "outputDir":
file_config.output.Add("output_dir", reader.Value);
break;
case "outputName":
file_config.output.Add("output_name", reader.Value);
break;
case "outputExt":
file_config.output.Add("output_ext", reader.Value);
break;
/* Email Config variables */
case "serverName":
email_config.email.Add("server_name", reader.Value);
break;
case "serverPort":
email_config.email.Add("server_port", reader.Value);
break;
case "senderEmail":
email_config.email.Add("sender_email", reader.Value);
break;
case "emailSubject":
email_config.email.Add("email_subject", reader.Value);
break;
case "emailBody":
email_config.email.Add("email_body", reader.Value);
break;
case "emailTemplate":
email_config.email.Add("email_template", reader.Value);
break;
case "emailType":
email_config.email.Add("email_type", reader.Value);
break;
/* Template config */
case "placeHolder":
string ph = reader.Value;
if (reader.MoveToNextAttribute()) {
if (reader.Name == "content") {
// Console.WriteLine("Template Markup defined: " + ph + " ; " + reader.Value);
template_config.markup_delim.Add(ph, reader.Value);
}
else
Console.WriteLine("Unknown template configuration attribute: " + reader.Name);
}
else
Console.WriteLine("Unable to process Template Attribute: " + ph);
break;
default:
Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
return false;
}
}
}
return true;
}