本文整理汇总了C#中XmlReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.Read方法的具体用法?C# XmlReader.Read怎么用?C# XmlReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public void Load(ref XmlReader reader)
{
print ("Loading Piece");
float tempX = -1;
float tempY = -1;
float tempZ = -1;
print ("Loading Piece");
while(reader.NodeType != XmlNodeType.EndElement){
reader.Read ();
if (reader.Name == "Texture"){
while(reader.NodeType != XmlNodeType.EndElement){
reader.Read ();
if(reader.NodeType == XmlNodeType.Text){
//texture.name = reader.Value;
}
}
//texture.name = reader.Value;
print ("Loading texture");
}
reader.Read();
if (reader.Name == "Direction"){
while(reader.NodeType != XmlNodeType.EndElement){
reader.Read ();
if(reader.NodeType == XmlNodeType.Text){
direction = reader.Value;
}
}
print ("Loading direction");
}
reader.Read();
if (reader.Name == "Type"){
while(reader.NodeType != XmlNodeType.EndElement){
reader.Read ();
if(reader.NodeType == XmlNodeType.Text){
type = reader.Value;
}
}
print ("Loading type");
}
reader.Read();
if(reader.Name == "Moves"){
while(reader.NodeType != XmlNodeType.EndElement)
{
reader.Read();
}
}
}
}
示例2: UploadButton_Click
protected void UploadButton_Click(object sender, EventArgs e)
{
var path = @"C:\Temp\Upload";
if (FileUpload.HasFile)
{
var filename = FileUpload.FileName;
path += filename;
FileUpload.SaveAs(path);
UploadStatusLabel.Text = "File saved as " + filename;
var reader = new XmlReader();
string orderXml = reader.Read(path);
var parser = new OrderParser();
var orderItems = parser.Parse(orderXml);
GridView.DataSource = new List<Order>(orderItems);
GridView.DataBind();
}
else
{
UploadStatusLabel.Text = "You did not specify a file to upload.";
}
}
示例3: XDeclaration
internal XDeclaration(XmlReader r)
{
_version = r.GetAttribute("version");
_encoding = r.GetAttribute("encoding");
_standalone = r.GetAttribute("standalone");
r.Read();
}
示例4: 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 ();
}
示例5: _NextToken
private bool _NextToken(XmlReader reader)
{
while (!reader.EOF && reader.Read() && !reader.IsStartElement())
;
return !reader.EOF;
}
示例6: XDocumentType
internal XDocumentType(XmlReader r)
{
_name = r.Name;
_publicId = r.GetAttribute("PUBLIC");
_systemId = r.GetAttribute("SYSTEM");
_internalSubset = r.Value;
r.Read();
}
示例7: OnSkillOver
public void OnSkillOver(GameObject gobject)
{
onOver = true;
XmlReader xr = new XmlReader();
var name = gobject.GetComponentInParent<Skill>().name;
int item = int.Parse(gobject.name) - 1;
info = xr.Read(xr.LoadFile("SkillsDescription"), name, item);
}
示例8: PrintNodesCore
public static void PrintNodesCore (XmlReader reader, Action onNode) {
int count = 0;
while (reader.Read()) {
count += 1;
onNode();
}
Console.WriteLine("// {0} node(s)", count);
}
示例9: ReadObject
public override object ReadObject(XmlReader reader)
{
ArrayOfLoanStateCompositeType ArrayOfLoanStateCompositeTypeField = null;
if (IsParentStartElement(reader, false, true))
{
ArrayOfLoanStateCompositeTypeField = new ArrayOfLoanStateCompositeType();
reader.Read();
LoanStateCompositeTypeDataContractSerializer LoanStateCompositeTypeDCS = new LoanStateCompositeTypeDataContractSerializer("LoanStateCompositeType", "http://schemas.datacontract.org/2004/07/", "http://schemas.datacontract.org/2004/07/");
System.Collections.ArrayList LoanStateCompositeType_List = new System.Collections.ArrayList();
for (int i = 0; (i > -1); i = (i + 1))
{
if (!IsChildStartElement(reader, "LoanStateCompositeType", false, false))
{
ArrayOfLoanStateCompositeTypeField.LoanStateCompositeType = new LoanStateCompositeType[LoanStateCompositeType_List.Count];
LoanStateCompositeType_List.CopyTo(ArrayOfLoanStateCompositeTypeField.LoanStateCompositeType);
break;
}
LoanStateCompositeType_List.Add(((LoanStateCompositeType)(LoanStateCompositeTypeDCS.ReadObject(reader))));
}
reader.ReadEndElement();
}
return ArrayOfLoanStateCompositeTypeField;
}
示例10: 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);
//.........这里部分代码省略.........
示例11: Foo
private void Foo(XmlReader reader)
{
reader.Read();
Bar(reader.ReadSubtree());
}
示例12: ParseContextSetupReply
public void ParseContextSetupReply(XmlReader reader)
{
// verify node is "context_setup_reply
if (reader.Name == "context_setup_reply")
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "apiversion")
{
csr.apiversion = reader.ReadElementContentAsString();
//UnityEngine.Debug.Log("apiversion=" + csr.apiversion);
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "setup_request_status")
{
csr.setup_request_status = reader.ReadElementContentAsInt();
//UnityEngine.Debug.Log("setup_request_status=" + csr.setup_request_status);
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "context_uid")
{
csr.context_uid = reader.ReadElementContentAsString();
#if SHOW_INIT
QuickInfoMsg msg = new QuickInfoMsg();
msg.title = "NLU STATUS";
msg.text = "NLU Initialized : " + CmdTime + " seconds";
msg.timeout = 2.0f;
QuickInfoDialog.GetInstance().PutMessage(msg);
#endif
Initialized = true;
//UnityEngine.Debug.Log("context_uid=" + csr.context_uid);
}
}
}
}
示例13: ParseUtteranceReply
public void ParseUtteranceReply(XmlReader reader)
{
pur = new process_utterance_reply();
// verify node is "context_setup_reply
if (reader.Name == "process_utterance_reply")
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "utterance_request_status")
{
pur.utterance_request_status = reader.ReadElementContentAsInt();
#if DEBUG_REPLY
UnityEngine.Debug.Log("utterance status=" + pur.utterance_request_status);
#endif
// report error
if (pur.utterance_request_status < 0 && errorCallback != null)
{
//'utterance_request_status' indicates if utterance process is final or NLU server starts
// 0: OK. the 'match_record' list contains the simulation command(s) for the utterance
// 1: NLU server executes 'clarifying NLU sub-session' (see "SiTEL-SMS API Reqs & Specs" document)
//-1: cannot process utterance
//-2: MLU not ready for utterance processing
//-3: missing utterance text
string error="none";
switch (pur.utterance_request_status)
{
case -1:
error = "error -1: cannot process utterance";
break;
case -2:
error = "error -2: MLU not ready for utterance processing";
break;
case -3:
error = "error -3: missing utterance text";
break;
}
errorCallback(error);
}
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "match_records")
{
List<sim_command_param> parameters=null;
List<missing_sim_command_param> missing = null;
match_record record = null;
while (reader.Read())
{
#if DEBUG_REPLY
if (reader.NodeType == XmlNodeType.Element)
UnityEngine.Debug.Log("NODE_NAME=" + reader.Name + ", NODE_TYPE=" + reader.NodeType.ToString());
else if (reader.NodeType == XmlNodeType.EndElement)
UnityEngine.Debug.Log("NODE_END=" + reader.Name + ", NODE_TYPE=" + reader.NodeType.ToString());
else
UnityEngine.Debug.Log("NODE_TYPE=" + reader.NodeType.ToString());
#endif
// match START element
if (reader.NodeType == XmlNodeType.Element && reader.Name == "match")
{
if (reader.IsEmptyElement == false)
{
record = new match_record();
if ( reader.MoveToAttribute("index") == false )
UnityEngine.Debug.Log("CAN'T FIND INDEX!");
record.index = reader.ReadContentAsInt();
if ( reader.MoveToAttribute("sim_command") == false )
UnityEngine.Debug.Log("CAN'T FIND SIM_COMMAND!");
record.sim_command = reader.ReadContentAsString();
if ( reader.MoveToAttribute("score") == false )
UnityEngine.Debug.Log("CAN'T FIND SCORE!");
record.score = reader.ReadContentAsFloat();
if ( reader.MoveToAttribute("input") == false )
UnityEngine.Debug.Log("CAN'T FIND INPUT!");
record.input = reader.ReadContentAsString();
#if DEBUG_REPLY
UnityEngine.Debug.Log("START MATCH : sim_command=" + record.sim_command);
#endif
}
}
// match END element
if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "match")
{
if (reader.IsEmptyElement == false)
{
#if DEBUG_REPLY
UnityEngine.Debug.Log("END MATCH");
#endif
pur.match_records.Add(record);
// do callback here, we have a valid match!!
if (utteranceCallback != null)
utteranceCallback(record);
record.Debug();
}
}
// sim command parameters
//.........这里部分代码省略.........
示例14: ReadElements
/// <summary>
/// Reads the elements from the loaded xmldocument in LoadResources
/// </summary>
/// <param name='reader'>
/// Reader.
/// </param>
private void ReadElements(XmlReader reader)
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
//If this is a chunk of data, then parse it
if (reader.Name == "data")
{
ReadData(reader);
}
break;
}
}
}
示例15: XComment
internal XComment(XmlReader r)
{
value = r.Value;
r.Read();
}