public static List<XmlNode> GetSuccessfulTestSuites(XmlNodeList xmlNodeList) { List<XmlNode> resultList = new List<XmlNode>(); for (int i = 0; i < xmlNodeList.Count; ++i) { XmlNode nameNode = xmlNodeList.Item(i).Attributes.GetNamedItem("name"); XmlNode successNode = xmlNodeList.Item(i).Attributes.GetNamedItem("success"); XmlNode executedNode = xmlNodeList.Item(i).Attributes.GetNamedItem("executed"); if (successNode == null) continue; if (executedNode == null) continue; try { if (successNode.Value.Equals("True")) resultList.Add(xmlNodeList.Item(i)); } catch (Exception ex) { //ignore... Logger.LogException(ex); } } return resultList; }
/// <summary> Populates the given Segment object with data from the given XML Element.</summary> /// <throws> HL7Exception if the XML Element does not have the correct name and structure </throws> /// <summary> for the given Segment, or if there is an error while setting individual field values. /// </summary> public virtual void parse(Segment segmentObject, System.Xml.XmlElement segmentElement) { SupportClass.HashSetSupport done = new SupportClass.HashSetSupport(); System.Xml.XmlNodeList all = segmentElement.ChildNodes; for (int i = 0; i < all.Count; i++) { System.String elementName = all.Item(i).Name; if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName)) { done.Add(elementName); int index = elementName.IndexOf('.'); if (index >= 0 && elementName.Length > index) { //properly formatted element System.String fieldNumString = elementName.Substring(index + 1); int fieldNum = System.Int32.Parse(fieldNumString); parseReps(segmentObject, segmentElement, elementName, fieldNum); } else { } } } //set data type of OBX-5 if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0) { Varies.fixOBX5(segmentObject, Factory); } }
static Setting() { m_settingsPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); m_settingsPath += @"\Setting.xml"; if (!File.Exists(m_settingsPath)) { throw new FileNotFoundException(m_settingsPath + " could not be found."); } System.Xml.XmlDocument xdoc = new XmlDocument(); xdoc.Load(m_settingsPath); XmlElement root = xdoc.DocumentElement; System.Xml.XmlNodeList nodeList = root.ChildNodes.Item(0).ChildNodes; // Add settings to the NameValueCollection. m_settings = new NameValueCollection(); for (int i = 0; i < nodeList.Count; i++) { m_settings.Add(nodeList.Item(i).Attributes["key"].Value, nodeList.Item(i).Attributes["value"].Value); } /* m_settings.Add("Index", nodeList.Item(0).Attributes["value"].Value); * m_settings.Add("Login", nodeList.Item(1).Attributes["value"].Value); * m_settings.Add("Password", nodeList.Item(2).Attributes["value"].Value); * * m_settings.Add("ServerIP", nodeList.Item(3).Attributes["value"].Value); * m_settings.Add("UserName", nodeList.Item(4).Attributes["value"].Value); * m_settings.Add("PhoneNumber", nodeList.Item(5).Attributes["value"].Value); * m_settings.Add("TimeOut", nodeList.Item(6).Attributes["value"].Value); * m_settings.Add("LastTransmit", nodeList.Item(7).Attributes["value"].Value); * m_settings.Add("DatabasePath", nodeList.Item(8).Attributes["value"].Value);*/ }
/// <summary> /// Adds appsettings lines to web.config file to control pooling, statemanagement, and workspace loading. /// </summary> /// <param name="xmlDoc">Document pointing to the web.config file.</param> internal static bool AddAppSettings(XmlDocument xmlDoc) { bool updated = false; XmlNode appSettingsNode = xmlDoc.SelectSingleNode("//appSettings"); if(appSettingsNode == null) { appSettingsNode = xmlDoc.CreateNode(XmlNodeType.Element, "appSettings", ""); System.Xml.XmlNodeList compNode = xmlDoc.GetElementsByTagName("configuration"); compNode.Item(0).InsertBefore(appSettingsNode, compNode.Item(0).FirstChild); updated = true; } if(appSettingsNode.SelectSingleNode("add[@key='MapInfo.Engine.Session.Pooled']") == null) { updated |= AddCommentNode(xmlDoc, appSettingsNode, L10NUtils.Resources.GetString("PooledSetting")); updated |= AddCommentNode(xmlDoc, appSettingsNode, "<add key=\"MapInfo.Engine.Session.Pooled\" value=\"false\" />"); } if(appSettingsNode.SelectSingleNode("add[@key='MapInfo.Engine.Session.State']") == null) { updated |= AddCommentNode(xmlDoc, appSettingsNode, L10NUtils.Resources.GetString("StateSetting")); updated |= AddCommentNode(xmlDoc, appSettingsNode, "<add key=\"MapInfo.Engine.Session.State\" value=\"HttpSessionState\" />"); } if(appSettingsNode.SelectSingleNode("add[@key='MapInfo.Engine.Session.Workspace']") == null) { updated |= AddCommentNode(xmlDoc, appSettingsNode, L10NUtils.Resources.GetString("WorkspaceSetting")); updated |= AddCommentNode(xmlDoc, appSettingsNode, "<add key=\"MapInfo.Engine.Session.Workspace\" value=\"c:\\my workspace.mws\" />"); } if(appSettingsNode.SelectSingleNode("add[@key='MapInfo.Engine.Session.UseCallContext']") == null) { updated |= AddCommentNode(xmlDoc, appSettingsNode, L10NUtils.Resources.GetString("UseCallContextSetting")); updated |= AddCommentNode(xmlDoc, appSettingsNode, "<add key=\"MapInfo.Engine.Session.UseCallContext\" value=\"true\" />"); } if(appSettingsNode.SelectSingleNode("add[@key='MapInfo.Engine.Session.RestoreWithinCallContext']") == null) { updated |= AddCommentNode(xmlDoc, appSettingsNode, L10NUtils.Resources.GetString("RestoreWithinCallContextSetting")); updated |= AddCommentNode(xmlDoc, appSettingsNode, "<add key=\"MapInfo.Engine.Session.RestoreWithinCallContext\" value=\"true\" />"); } return updated; }
protected void Page_Load(object sender, EventArgs e) { var objRSS = new RSS(); objRSS.ExecuteUrlRead(); System.Xml.XmlNodeList rssItems = objRSS.Document.SelectNodes("rss/channel/item"); string title = ""; string link = ""; string description = ""; objRSS.LstRSS = new List <RSSItem>(); for (int i = 0; i < rssItems.Count; i++) { System.Xml.XmlNode rssDetail; rssDetail = rssItems.Item(i).SelectSingleNode("title"); if (rssDetail != null) { title = rssDetail.InnerText; } else { title = ""; } rssDetail = rssItems.Item(i).SelectSingleNode("link"); if (rssDetail != null) { link = rssDetail.InnerText; } else { link = ""; } rssDetail = rssItems.Item(i).SelectSingleNode("description"); if (rssDetail != null) { description = rssDetail.InnerText; } else { description = ""; } objRSS.LstRSS.Add(new RSSItem { Title = title, Description = description, Link = link }); } rptRSS.DataSource = objRSS.LstRSS; rptRSS.DataBind(); }
public IEnumerator loaddata() { string url = npclistname; WWW www = new WWW(url); yield return(www); if (www.error == null) { //Debug.LogError("loading npclist"); //no error occured string xml = www.data; // Debug.Log(xml); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); System.Xml.XmlNodeList NpcListNodes = xmlDoc.GetElementsByTagName("Npcs"); if (NpcListNodes.Count > 0) { XmlElement coun = (XmlElement)NpcListNodes.Item(0); ReadNpcList(coun); } } www.Dispose(); www = null; }
/// <summary>Removes attributes, comments, and processing instructions. </summary> private static void clean(System.Xml.XmlElement elem) { System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode child = children.Item(i); if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.ProcessingInstruction || System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Comment) { elem.RemoveChild(child); } else if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Element) { clean((System.Xml.XmlElement)child); } } System.Xml.XmlNamedNodeMap attributes = (System.Xml.XmlAttributeCollection)elem.Attributes; //get names System.String[] names = new System.String[attributes.Count]; for (int i = 0; i < names.Length; i++) { names[i] = attributes.Item(i).Name; } //remove by name for (int i = 0; i < names.Length; i++) { attributes.RemoveNamedItem(names[i]); } }
public static GuidanceShift Load(XmlNodeList inputNode, TaskDataDocument taskDataDocument) { var loader = new GuidanceShiftLoader(taskDataDocument); var node = inputNode.Item(0); return loader.Load(node); }
internal static bool AddSessionState(XmlDocument xmlDoc) { bool updated = false; XmlNode sessStateNode = xmlDoc.SelectSingleNode("//sessionState"); if (sessStateNode == null) { sessStateNode = xmlDoc.CreateNode(XmlNodeType.Element, "sessionState", ""); System.Xml.XmlAttribute addAttrib1 = xmlDoc.CreateAttribute("mode"); addAttrib1.Value = "StateServer"; sessStateNode.Attributes.Append(addAttrib1); System.Xml.XmlAttribute addAttrib2 = xmlDoc.CreateAttribute("stateConnectionString"); addAttrib2.Value = "tcpip=127.0.0.1:42424"; sessStateNode.Attributes.Append(addAttrib2); System.Xml.XmlAttribute addAttrib3 = xmlDoc.CreateAttribute("sqlConnectionString"); addAttrib3.Value = "data source=127.0.0.1;user id=sa;password="******"cookieless"); addAttrib4.Value = "false"; sessStateNode.Attributes.Append(addAttrib4); System.Xml.XmlAttribute addAttrib5 = xmlDoc.CreateAttribute("timeout"); addAttrib5.Value = "20"; sessStateNode.Attributes.Append(addAttrib5); System.Xml.XmlNodeList sysNode = xmlDoc.GetElementsByTagName("system.web"); sysNode.Item(0).AppendChild(sessStateNode); updated = true; } return updated; }
/// <summary>Parses a segment profile </summary> private Seg parseSegmentProfile(System.Xml.XmlElement elem) { Seg segment = new Seg(); parseProfileStuctureData(segment, elem); int childIndex = 1; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("Field".ToUpper())) { Field field = parseFieldProfile(child); segment.setField(childIndex++, field); } } } return(segment); }
private void readDeptConfig() { //this function go to the department config file and get a list of all the departments that use //tracker. It also checks to see if the application is associated with a dept. If not then the program //will not be able to load the correct setting (which depend on the appropriate xml file try { DeptLookupHash = new Hashtable(); XmlDocument doc = new XmlDocument(); doc.Load("http://www.cs.mun.ca/~thecommons/configfiles/TrackerDeptConfig.xml"); System.Xml.XmlNodeList ttt = doc.SelectNodes("tracker/dept-options/dept"); //now we want to get all the issues and populate the list box for (int i = 0; i < ttt.Count; i++) { System.Xml.XmlNode theNode = ttt.Item(i); DeptLookupHash.Add(i, theNode.SelectSingleNode("@name").Value); } //Now get file the correct url for the department string xpathDept = "tracker/dept-options/dept[@name='" + strDept + "']"; System.Xml.XmlNode theElement = doc.SelectSingleNode(xpathDept); strDeptUrl = theElement.SelectSingleNode("@url").Value; } catch { MessageBox.Show("There was a problem detecting which department you belong to -please make sure your department setting are correct and Dept xml file is formatted properly", "Tracker"); } }
protected override void ExecuteTask() { if (srcurl.EndsWith("/") == false) { srcurl += "/"; } if (destdir.EndsWith("\\") == false) { destdir += "\\"; } if (oldrev == "0") { NoshellProcess.Execute("svn", string.Format("export --force -r {0} {1} {2}", newrev, srcurl, destdir)); } else { System.Xml.XmlDocument xml = NoshellProcess.ExcuteXML("svn", string.Format("diff -r {0}:{1} --summarize --xml {2}", oldrev, newrev, srcurl)); System.Xml.XmlNodeList nodes = xml.SelectNodes("/diff/paths/path"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes.Item(i); string kind = node.Attributes["kind"].Value; string props = node.Attributes["props"].Value; string item = node.Attributes["item"].Value; string path = node.InnerXml.Replace(srcurl, "").Replace("/", "\\"); if (item == "none" && props != "none") { item = props; } if (kind == "file") { string destfilename = System.IO.Path.Combine(destdir, path); if (System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(destfilename)) == false) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destfilename)); } System.Console.WriteLine(string.Format("Export {0}", path)); NoshellProcess.Execute("svn", string.Format("export --force -r {0} {1} {2}", newrev, node.InnerXml, destfilename)); } } } // 마지막으로 익스포트 된 파일을 전부 소문자로 변환한다. // 안하면 문제의 여지가 있다 ConvertLowerCase(destdir); AddPatchInfo(System.IO.Path.Combine(destdir, "patchinfo.xml"), "PatcherFiles", patcherfiles); AddPatchInfo(System.IO.Path.Combine(destdir, "patchinfo.xml"), "VerifyFiles", verifyfiles); }
private void readConfigfile() { try { readDeptConfig(); // Declare a Hashtable object: issueLookupHash = new Hashtable(); XmlDocument doc = new XmlDocument(); doc.Load(strDeptUrl); //note: Should look something like: http://www.cs.mun.ca/~thecommons/configfiles/TrackerConfig.xml System.Xml.XmlNodeList ttt = doc.SelectNodes("tracker/issue-options/issue"); //now we want to get all the issues and populate the list box for (int i = 0; i < ttt.Count; i++) { System.Xml.XmlNode theNode = ttt.Item(i); issueLookupHash.Add(i, theNode.SelectSingleNode("@name").Value); //lbIssues.Items.Add (theNode.SelectSingleNode("@name").Value); } strDataFile = doc.SelectSingleNode("tracker/datafile/@name").Value; strRoundsFile = doc.SelectSingleNode("tracker/roundsfile/@name").Value; //Now get the data for the buttons (note: this should be turned into a enum at some point System.Xml.XmlNode theElement = doc.SelectSingleNode("tracker/appslist/app[@btn='btnApp1']"); strBtn1 = theElement.SelectSingleNode("@name").Value; strBtnValue1 = theElement.SelectSingleNode("@location").Value; System.Xml.XmlNode theElement2 = doc.SelectSingleNode("tracker/appslist/app[@btn='btnApp2']"); strBtn2 = theElement2.SelectSingleNode("@name").Value; strBtnValue2 = theElement2.SelectSingleNode("@location").Value; System.Xml.XmlNode theElement3 = doc.SelectSingleNode("tracker/appslist/app[@btn='btnApp3']"); strBtn3 = theElement3.SelectSingleNode("@name").Value; strBtnValue3 = theElement3.SelectSingleNode("@location").Value; System.Xml.XmlNode theElement4 = doc.SelectSingleNode("tracker/appslist/app[@btn='btnApp4']"); strBtn4 = theElement4.SelectSingleNode("@name").Value; strBtnValue4 = theElement4.SelectSingleNode("@location").Value; System.Xml.XmlNode theElement5 = doc.SelectSingleNode("tracker/appslist/app[@btn='btnApp5']"); strBtn5 = theElement5.SelectSingleNode("@name").Value; strBtnValue5 = theElement5.SelectSingleNode("@location").Value; System.Xml.XmlNode theElement6 = doc.SelectSingleNode("tracker/helpbutton/complocation"); strCompLocationURL = theElement6.SelectSingleNode("@url").Value; System.Xml.XmlNode helpButtonElement = doc.SelectSingleNode("tracker/helpbutton/complocation"); strCompLocationURL = helpButtonElement.SelectSingleNode("@url").Value; System.Xml.XmlNode roundsElement = doc.SelectSingleNode("tracker/config/rounds-on"); boolRoundsOn = Convert.ToBoolean(roundsElement.SelectSingleNode("@truefalse").Value); System.Xml.XmlNode closingElement = doc.SelectSingleNode("tracker/config/closing-on"); boolClosingOn = Convert.ToBoolean(roundsElement.SelectSingleNode("@truefalse").Value); } catch { MessageBox.Show("There was a problem loading-- " + strDataFile + " --please make sure it exists and is formatted properly", "Tracker"); } }
/// <summary> /// Adds lines containing httpmodules to web.config file. /// </summary> /// <param name="xmlDoc">Document pointing to web.config file.</param> /// <remarks>This module handles the MapInfo session creation.</remarks> internal static bool AddHttpModules(XmlDocument xmlDoc) { bool updated = false; // Now create httphandler node XmlNode httpNode = xmlDoc.SelectSingleNode("//httpModules"); if (httpNode == null) { httpNode = xmlDoc.CreateNode(XmlNodeType.Element, "httpModules", ""); } string searchStr = string.Format("//add[contains(@type, '{0}')]", "MapInfo.Engine.WebSessionActivator"); XmlNode node = xmlDoc.SelectSingleNode(searchStr); AssemblyName coreEngineAssembly = typeof(MapInfo.Engine.WebSessionActivator).Assembly.GetName(); if (RemoveEntry(node, coreEngineAssembly, "type")) { XmlNode addNode = xmlDoc.CreateNode(XmlNodeType.Element, "add", ""); System.Xml.XmlAttribute addAttrib1 = xmlDoc.CreateAttribute("type"); addAttrib1.Value = string.Format("{0}, {1}", "MapInfo.Engine.WebSessionActivator", coreEngineAssembly.FullName); addNode.Attributes.Append(addAttrib1); System.Xml.XmlAttribute addAttrib2 = xmlDoc.CreateAttribute("name"); addAttrib2.Value = "WebSessionActivator"; addNode.Attributes.Append(addAttrib2); httpNode.AppendChild(addNode); updated = true; } // Now insert this information into system.web node in the file if (updated) { System.Xml.XmlNodeList sysNode = xmlDoc.GetElementsByTagName("system.web"); sysNode.Item(0).AppendChild(httpNode); } return updated; }
/// <summary> Populates a Composite type by looping through it's children, finding corresponding /// Elements among the children of the given Element, and calling parse(Type, Element) for /// each. /// </summary> private void parseComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement) { if (datatypeObject is GenericComposite) { //elements won't be named GenericComposite.x System.Xml.XmlNodeList children = datatypeElement.ChildNodes; int compNum = 0; for (int i = 0; i < children.Count; i++) { if (System.Convert.ToInt16(children.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element) { parse(datatypeObject.getComponent(compNum), (System.Xml.XmlElement)children.Item(i)); compNum++; } } } else { Type[] children = datatypeObject.Components; for (int i = 0; i < children.Length; i++) { System.Xml.XmlNodeList matchingElements = datatypeElement.GetElementsByTagName(makeElementName(datatypeObject, i + 1)); if (matchingElements.Count > 0) { parse(children[i], (System.Xml.XmlElement)matchingElements.Item(0)); //components don't repeat - use 1st } } } }
/// <summary>Parses a primitive type by filling it with text child, if any </summary> private void parsePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement) { System.Xml.XmlNodeList children = datatypeElement.ChildNodes; int c = 0; bool full = false; while (c < children.Count && !full) { System.Xml.XmlNode child = children.Item(c++); if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Text) { try { if (child.Value != null && !child.Value.Equals("")) { if (keepAsOriginal(child.ParentNode)) { datatypeObject.Value = child.Value; } else { datatypeObject.Value = removeWhitespace(child.Value); } } } catch (System.Exception) { } full = true; } } }
private System.Xml.XmlNodeList getSourceFieldNodes() { System.Xml.XmlNodeList nodes = null; if (FieldGrid.SelectedIndex == -1) { return(nodes); } int fieldnum = FieldGrid.SelectedIndex + 1; System.Xml.XmlNodeList fnodes = getFieldNodes(fieldnum); string sname = ""; try { sname = fnodes.Item(0).SelectSingleNode("SourceName").InnerText; } catch { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Could not find SourceName element for field (row) number " + fieldnum.ToString()); return(nodes); } string xpath = "//SourceField[@Name='" + sname + "']"; // Source field values System.Xml.XmlNodeList nodelist = _xml.SelectNodes(xpath); if (nodelist != null && nodelist.Count == 1) { return(nodelist); } else { return(nodes); } }
/// <summary>Parses a component profile </summary> private AbstractComponent parseComponentProfile(System.Xml.XmlElement elem, bool isSubComponent) { AbstractComponent comp = null; if (isSubComponent) { comp = new SubComponent(); } else { comp = new Component(); int childIndex = 1; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("SubComponent".ToUpper())) { SubComponent subcomp = (SubComponent)parseComponentProfile(child, true); ((Component)comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return(comp); }
/* public void HTMLNodeObject(string argFirst,int argSecond) * { * string tagName = argFirst;//arguments[0]; * //int one = 1; * //int two = 2; * System.Xml.XmlNodeList nodeList=null; * * if (tagName==FRAMESET || tagName==FRAME) * nodeList = framesetdoc.GetElementsByTagName(tagName); * else * nodeList = testdoc.GetElementsByTagName(tagName); * * if (argFirst != "") //if (arguments.length == one) * this.node = nodeList.Item(util.FIRST); * if (argSecond != -1) //else if (arguments.length == two) * this.node = nodeList.Item(argSecond);//arguments[SECOND]); * } * * public System.Xml.XmlNode originalHTMLDocument(string arg) * { * string tagName = arg; * //int one = 1; * //int two = 2; * * System.Xml.XmlNodeList nodeList = originaldoc.GetElementsByTagName(tagName); * this.node = nodeList.Item(util.FIRST).CloneNode(true); * return this.node; * } */ // public string getTableCaption(object table) // { // return table.caption; // } // // public void getTableHead(object table) // { // return table.tHead; // } // // public void getTableFoot(object table) // { // return table.tFoot; // } public static System.Xml.XmlNode nodeObject(int argFirst, int argSecond)//args) { string tagName = employee; System.Xml.XmlNodeList nodeList = null; System.Xml.XmlNode _node = null; nodeList = getRootNode().GetElementsByTagName(tagName); System.Xml.XmlElement parentNode = (System.Xml.XmlElement)nodeList.Item(argFirst); //arguments[FIRST]); if (argFirst != -1) //if (arguments.length == one) { _node = parentNode; } if (argSecond != -1)//else if (arguments.length == two) { System.Xml.XmlNodeList list = getSubNodes(parentNode); _node = getElement(getSubNodes(parentNode), argSecond);//arguments[SECOND]); //_node = getElement((System.Xml.XmlNodeList)getSubNodes(parentNode), argSecond);//arguments[SECOND]); } //_attributes = getAttributes(_node); //_subNodes = getSubNodes((System.Xml.XmlElement)_node); return(_node); }
public static List <RestApiProjectDoc> GetProjectDocs(System.Xml.XmlNodeList xmlProjects) { var projects = new List <RestApiProjectDoc>(); for (int i = 0; i < xmlProjects.Count; i++) { var attributes = xmlProjects.Item(i).Attributes; if (attributes != null) { var project = new RestApiProjectDoc() { Description = GetAttribute(attributes, "description"), Id = GetAttribute(attributes, "id"), Href = GetAttribute(attributes, "href"), Name = GetAttribute(attributes, "name"), WebUrl = GetAttribute(attributes, "webUrl") }; projects.Add(project); } } return(projects); }
/// <summary>Parses a field profile </summary> private Field parseFieldProfile(System.Xml.XmlElement elem) { Field field = new Field(); field.Usage = elem.GetAttribute("Usage"); System.String itemNo = elem.GetAttribute("ItemNo"); System.String min = elem.GetAttribute("Min"); System.String max = elem.GetAttribute("Max"); try { if (itemNo.Length > 0) { field.ItemNo = System.Int16.Parse(itemNo); } } catch (System.FormatException e) { throw new NuGenProfileException("Invalid ItemNo: " + itemNo + "( for name " + elem.GetAttribute("Name") + ")", e); } // try-catch try { field.Min = System.Int16.Parse(min); if (max.IndexOf('*') >= 0) { field.Max = (short)(-1); } else { field.Max = System.Int16.Parse(max); } } catch (System.FormatException e) { throw new NuGenProfileException("Min and max must be short integers: " + min + ", " + max, e); } parseAbstractComponentData(field, elem); int childIndex = 1; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("Component".ToUpper())) { Component comp = (Component)parseComponentProfile(child, false); field.setComponent(childIndex++, comp); } } } return(field); }
private void parseReps(Segment segmentObject, System.Xml.XmlElement segmentElement, System.String fieldName, int fieldNum) { System.Xml.XmlNodeList reps = segmentElement.GetElementsByTagName(fieldName); for (int i = 0; i < reps.Count; i++) { parse(segmentObject.getField(fieldNum, i), (System.Xml.XmlElement)reps.Item(i)); } }
private String[,] getRssData(String channel) { System.Net.WebRequest myRequest = System.Net.WebRequest.Create(channel); System.Net.WebResponse myResponse = myRequest.GetResponse(); System.IO.Stream rssStream = myResponse.GetResponseStream(); System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument(); rssDoc.Load(rssStream); System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item"); String[,] tempRssData = new String[rssItems.Count, 3]; for (int i = 0; i < rssItems.Count; i++) { System.Xml.XmlNode rssNode; rssNode = rssItems.Item(i).SelectSingleNode("title"); if (rssNode != null) { tempRssData[i, 0] = rssNode.InnerText; } else { tempRssData[i, 0] = ""; } rssNode = rssItems.Item(i).SelectSingleNode("description"); if (rssNode != null) { tempRssData[i, 1] = rssNode.InnerText; } else { tempRssData[i, 1] = ""; } rssNode = rssItems.Item(i).SelectSingleNode("link"); if (rssNode != null) { tempRssData[i, 2] = rssNode.InnerText; } else { tempRssData[i, 2] = ""; } } return(tempRssData); }
/// <summary>Read Element named mime-type. </summary> private MimeType ReadMimeType(System.Xml.XmlElement element) { System.String name = null; System.String description = null; MimeType type = null; System.Xml.XmlNamedNodeMap attrs = (System.Xml.XmlAttributeCollection)element.Attributes; for (int i = 0; i < attrs.Count; i++) { System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)attrs.Item(i); if (attr.Name.Equals("name")) { name = attr.Value; } else if (attr.Name.Equals("description")) { description = attr.Value; } } if ((name == null) || (name.Trim().Equals(""))) { return(null); } try { //System.Diagnostics.Trace.WriteLine("Mime type:" + name); type = new MimeType(name); } catch (MimeTypeException mte) { // Mime Type not valid... just ignore it System.Diagnostics.Trace.WriteLine(mte.ToString() + " ... Ignoring!"); return(null); } type.Description = description; System.Xml.XmlNodeList nodes = element.ChildNodes; for (int i = 0; i < nodes.Count; i++) { System.Xml.XmlNode node = nodes.Item(i); if (System.Convert.ToInt16(node.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement nodeElement = (System.Xml.XmlElement)node; if (nodeElement.Name.Equals("ext")) { ReadExt(nodeElement, type); } else if (nodeElement.Name.Equals("magic")) { ReadMagic(nodeElement, type); } } } return(type); }
/// <summary> Returns the first child element of the given parent that matches the given /// tag name. Returns null if no instance of the expected element is present. /// </summary> private System.Xml.XmlElement getFirstElementByTagName(System.String name, System.Xml.XmlElement parent) { System.Xml.XmlNodeList nl = parent.GetElementsByTagName(name); System.Xml.XmlElement ret = null; if (nl.Count > 0) { ret = (System.Xml.XmlElement)nl.Item(0); } return(ret); }
//取得XML //Public Shared Function GetInfoData(ByVal s As String) As String // Dim doc As XmlDocument = New XmlDocument // Dim sPath As String = Application.StartupPath + "\Connect\Connecting.xml" // Dim reader As New XmlTextReader(sPath) // reader.WhitespaceHandling = WhitespaceHandling.None // reader.MoveToContent() // reader.Read() // 'reader.Skip() 'Skip the first book. // 'reader.Skip() 'Skip the second book. // doc.Load(reader) // ' Move to an element. // Dim XmlElement As XmlElement // XmlElement = doc.DocumentElement // ' Get an attribute. // Dim attr As XmlAttribute // attr = XmlElement.GetAttributeNode(s) // 'Debug.WriteLine(attr.InnerText) // doc = Nothing // reader = Nothing // Return attr.InnerText // 'Dim i As Integer // 'For i = 0 To XmlElement.Attributes.Count - 1 // ' Debug.Write(XmlElement.Attributes(i).Name + ":" + XmlElement.Attributes(i).InnerText) // 'Next i // 'If XmlElement.HasChildNodes Then // ' For i = 0 To XmlElement.ChildNodes.Count - 1 // ' Debug.Write(XmlElement.ChildNodes(i).Name + ":" + XmlElement.ChildNodes(i).InnerText + vbCrLf) // ' Next i // 'End If //End Function private static void chkNode(ref XmlDocument xmlDoc, string ChildName) { XmlNodeList elemList = xmlDoc.GetElementsByTagName(ChildName); if (elemList.Count == 0) { System.Xml.XmlNodeList elemList2 = xmlDoc.GetElementsByTagName("Info").Item(0).ChildNodes; elemList2.Item(0).AppendChild(xmlDoc.CreateElement(ChildName)); } }
/// <summary> /// GetSetingArr /// </summary> /// <param name="lstSetting"></param> /// <param name="dt"></param> private void GetSetingArr(ref List <EntityAppConfig> lstSetting, DataTable dt) { List <string> lstNode = new List <string>() { "Service" }; System.Xml.XmlNodeList nodeList = null; System.Xml.XmlNode node = null; EntityAppConfig vo = null; string xml = string.Empty; foreach (DataRow dr in dt.Rows) { if (dr["setting"] != DBNull.Value && !string.IsNullOrEmpty(dr["setting"].ToString())) { xml = "<Main>" + Environment.NewLine + dr["setting"].ToString().Replace("<Parms>", "").Replace("</Parms>", "") + Environment.NewLine + "</Main>"; foreach (string nodeName in lstNode) { nodeList = Function.ReadXML(xml, nodeName); if (nodeList != null) { for (int i = 0; i < nodeList.Count; i++) { node = nodeList.Item(i); if (node.Attributes == null) { continue; } vo = new EntityAppConfig(); vo.Node = nodeName; vo.Module = node.Attributes["module"].Value.Trim(); vo.Name = node.Attributes["name"].Value.Trim(); vo.Text = node.Attributes["text"].Value.Trim(); vo.Value = node.Attributes["value"].Value.Trim(); if (lstSetting.Exists(t => t.Node == vo.Node && t.Module == vo.Module && t.Name == vo.Name)) { continue; } else { lstSetting.Add(vo); } } } } } } }
/// <summary>Parses common features of AbstractComponents (ie field, component, subcomponent) </summary> private void parseAbstractComponentData(AbstractComponent comp, System.Xml.XmlElement elem) { comp.Name = elem.GetAttribute("Name"); comp.Usage = elem.GetAttribute("Usage"); comp.Datatype = elem.GetAttribute("Datatype"); System.String length = elem.GetAttribute("Length"); if (length != null && length.Length > 0) { try { comp.Length = System.Int64.Parse(length); } catch (System.FormatException e) { throw new NuGenProfileException("Length must be a long integer: " + length, e); } } comp.ConstantValue = elem.GetAttribute("ConstantValue"); System.String table = elem.GetAttribute("Table"); if (table != null && table.Length > 0) { try { comp.Table = table; } catch (System.FormatException e) { throw new NuGenProfileException("Table must be a short integer: " + table, e); } } comp.ImpNote = getValueOfFirstElement("ImpNote", elem); comp.Description = getValueOfFirstElement("Description", elem); comp.Reference = getValueOfFirstElement("Reference", elem); comp.Predicate = getValueOfFirstElement("Predicate", elem); int dataValIndex = 0; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("DataValues".ToUpper())) { DataValue val = new DataValue(); val.ExValue = child.GetAttribute("ExValue"); comp.setDataValues(dataValIndex++, val); } } } }
/// <summary>Read Element named ext. </summary> private void ReadExt(System.Xml.XmlElement element, MimeType type) { System.Xml.XmlNodeList nodes = element.ChildNodes; for (int i = 0; i < nodes.Count; i++) { System.Xml.XmlNode node = nodes.Item(i); if (System.Convert.ToInt16(node.NodeType) == (short)System.Xml.XmlNodeType.Text) { type.AddExtension(((System.Xml.XmlText)node).Data); } } }
private void setSubstringValues(string start, string length) { try { setSliderValue(81, start); System.Xml.XmlNodeList source = getSourceFieldNodes(); int max = Int32.Parse(source.Item(0).Attributes.GetNamedItem("Length").InnerText); Method82Slider.Maximum = max; setSliderValue(82, length); } catch { } }
private static void ProcessWaypoints(XmlNodeList waypoints, IWriter p_writer) { if (waypoints.Count != 0) { XmlNamespaceManager nsmgr = new XmlNamespaceManager(waypoints.Item(0).OwnerDocument.NameTable); nsmgr.AddNamespace(ms_defaultNamespace, waypoints.Item(0).OwnerDocument.DocumentElement.NamespaceURI); foreach (XmlNode mark in waypoints) { decimal lat = Decimal.Parse(mark.Attributes.GetNamedItem(ms_gpx_lat).Value, Utils.ms_formatProviderEn); decimal lng = Decimal.Parse(mark.Attributes.GetNamedItem(ms_gpx_lon).Value, Utils.ms_formatProviderEn); String name = mark.SelectSingleNode(GetFullName(ms_gpx_name), nsmgr).InnerText; XmlNode elevationtNode = mark.SelectSingleNode(GetFullName(ms_gpx_ele), nsmgr); int elevation = elevationtNode != null ? Decimal.ToInt32(Decimal.Parse(elevationtNode.InnerText, Utils.ms_formatProviderEn)) : 0; XmlNode linkNode = mark.SelectSingleNode(GetFullName("link"), nsmgr); String link = linkNode != null ? linkNode.Attributes.GetNamedItem("href").Value : String.Empty; p_writer.AddWayPoint(name, lat, lng, elevation, link); } } }
/// <summary>Returns true if any of the given element's children are elements </summary> private bool hasChildElement(System.Xml.XmlElement e) { System.Xml.XmlNodeList children = e.ChildNodes; bool hasElement = false; int c = 0; while (c < children.Count && !hasElement) { if (System.Convert.ToInt16(children.Item(c).NodeType) == (short)System.Xml.XmlNodeType.Element) { hasElement = true; } c++; } return(hasElement); }
// Set un épisode d'un podcast private string getRssItem(XmlNodeList rssItems, int iCurrentNode, string rssItemAttribute) { string returnedValue = ""; XmlNode rssNode = rssItems.Item(iCurrentNode).SelectSingleNode(rssItemAttribute); if (rssNode != null) { returnedValue = rssNode.InnerText; } else { returnedValue = ""; } return returnedValue; }
/// <summary> /// Adds the line containing the HttpHandler to the web.config file. /// </summary> /// <param name="xmlDoc">Document pointing to the web.config file.</param> /// <param name="handlerName">Name of the HttpHandler.</param> /// <param name="className">Namespace and the classname of the handler.</param> /// <remarks>This method is only used at design time to automatically update the web.config file with appropriate handlers.</remarks> internal static bool AddController(XmlDocument xmlDoc, string handlerName, string className) { bool updated = false; // Now create httphandler node XmlNode httpNode = xmlDoc.SelectSingleNode("//httpHandlers"); if (httpNode == null) { httpNode = xmlDoc.CreateNode(XmlNodeType.Element, "httpHandlers", ""); } updated = AddHttpNode(xmlDoc, httpNode, handlerName, className); // Now insert this information into system.web node in the file if (updated) { System.Xml.XmlNodeList sysNode = xmlDoc.GetElementsByTagName("system.web"); sysNode.Item(0).AppendChild(httpNode); } return updated; }
private void Browser_Load(object sender, EventArgs e) { try { d = new XmlDocument(); d.Load(filename); fav = d.SelectNodes("favorite/site"); XmlNode site; for (int i = 0; i < fav.Count; i++) { site = fav.Item(i).SelectSingleNode("titlu"); favcombobox.Items.Add(site.InnerText); } } catch { ok = false; } if (ok == false) { XmlTextWriter writer = new XmlTextWriter("favorite.xml", Encoding.Unicode); writer.Formatting = Formatting.Indented; writer.WriteStartElement("favorite"); writer.WriteStartElement("site"); writer.WriteStartElement("titlu"); writer.WriteString("Google"); writer.WriteEndElement(); writer.WriteStartElement("url"); writer.WriteString("http://www.google.com/"); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); writer.Close(); ok = true; } }
public bool AddNodes(XmlNodeList oSourceList, String sName, String sParent) { try { if (oSourceList != null) { // call AddNode for each item in the source node list // return true only if all nodes are added successfully int i = 0; while (i < oSourceList.Count) { if (!AddNode(oSourceList.Item(i), sName, sParent)) return false; i++; } return true; } } catch (Exception) { // error handling code } return false; }
//-------------------------------------------------------------------------------------------------// public static string GetXmlValue(XmlNodeList xmlNodeList, int index, string strXmlNode, bool allowEmpty) { if (index < 0 || index >= xmlNodeList.Count) { throw new ArgumentOutOfRangeException(STRERR_XmlNodeListIndexInvalid); } // Get node's value string innerXml = xmlNodeList.Item(index).InnerXml.Trim(); // // Check if value is empty // if (allowEmpty == false && innerXml.Length == 0) { throw new ArgumentNullException(strXmlNode, STRERR_XmlNodeIsEmpty); } return innerXml; }
/// <summary> /// Builds a snippet from xml node. /// </summary> /// <param name="xmlNodeList">The xml node list.</param> /// <returns>The built snippet.</returns> private string BuildSnippet(XmlNodeList xmlNodeList) { // Data validation if(xmlNodeList == null) { throw new ArgumentNullException(nameof(xmlNodeList)); } // Extract code from each snippets StringBuilder stringBuilder = new StringBuilder(); bool firstSnippet = true; for (int i = 0; i < xmlNodeList.Count; ++i) { // Get the current node XmlNode node = xmlNodeList.Item(i); // Write line return between each snippet if (!firstSnippet) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); } // Write each snippet XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; settings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings)) { node.WriteTo(xmlWriter); } // Flag the first snippet as false firstSnippet = false; } // Remove all generate namespace declaration // This is produce some output lacking of namespace declaration but it's what is relevant for a xml document extraction string output = stringBuilder.ToString(); return Regex.Replace(output, @" ?xmlns\s*(:[^=]+)?\s*=\s*""[^""]*""", string.Empty) ?? string.Empty; }
private void iniVariants(XmlNodeList nodes, XmlNamespaceManager names, out string[] outStrings) { outStrings = new string[nodes.Count]; for (int i = 0; i < nodes.Count; i++) outStrings[i] = nodes.Item(i).SelectSingleNode("text()", names).Value; }
private void stergeToolStripMenuItem_Click(object sender, EventArgs e) { if (ok == true) { d = new XmlDocument(); d.Load(filename); XmlElement root = d.DocumentElement; foreach (XmlNode node in root) { if (node["titlu"].InnerText == favcombobox.Text) { node.ParentNode.RemoveChild(node); break; } } d.Save(filename); favcombobox.Items.Clear(); favcombobox.Text = ""; fav = d.SelectNodes("favorite/site"); XmlNode site; for (int i = 0; i < fav.Count; i++) { site = fav.Item(i).SelectSingleNode("titlu"); favcombobox.Items.Add(site.InnerText); } } }
protected double getVal(XmlNodeList cells, int index) { string val=cells.Item(index).InnerText; val = string.IsNullOrEmpty(val) ? "0" : val; val=val.Trim(); double res=0; try { res = Double.Parse(val.Replace(',','.')); } catch { } return res; }
private GradientStopCollection GetGradientStops(XmlNodeList stops) { int itemCount = stops.Count; GradientStopCollection gradientStops = new GradientStopCollection(itemCount); double lastOffset = 0; for (int i = 0; i < itemCount; i++) { SvgStopElement stop = (SvgStopElement)stops.Item(i); string prop = stop.GetAttribute("stop-color"); string style = stop.GetAttribute("style"); Color color = Colors.Transparent; // no auto-inherited... if (!String.IsNullOrEmpty(prop) || !String.IsNullOrEmpty(style)) { WpfSvgColor svgColor = new WpfSvgColor(stop, "stop-color"); color = svgColor.Color; } else { color = Colors.Black; // the default color... double alpha = 255; string opacity; opacity = stop.GetAttribute("stop-opacity"); // no auto-inherit if (opacity == "inherit") // if explicitly defined... { opacity = stop.GetPropertyValue("stop-opacity"); } if (opacity != null && opacity.Length > 0) alpha *= SvgNumber.ParseNumber(opacity); alpha = Math.Min(alpha, 255); alpha = Math.Max(alpha, 0); color = Color.FromArgb((byte)Convert.ToInt32(alpha), color.R, color.G, color.B); } double offset = stop.Offset.AnimVal; offset /= 100; offset = Math.Max(lastOffset, offset); gradientStops.Add(new GradientStop(color, offset)); lastOffset = offset; } if (itemCount == 0) { gradientStops.Add(new GradientStop(Colors.Black, 0)); gradientStops.Add(new GradientStop(Colors.Black, 1)); } return gradientStops; }
/// <summary> /// Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. /// </summary> /// <param name="nodelist"></param> /// <param name="primaryKey"></param> /// <returns></returns> public static DataTable GetDataTable( XmlNodeList nodelist, string primaryKeyColumn, bool autoIncrement) { DataTable table = null; XmlNode node = null; if ( nodelist == null ) return null; // get parameter names node = nodelist.Item( 0 ); if ( node == null ) return null; XmlAttributeCollection attrCollection = node.Attributes; if ( attrCollection == null ) return null; if ( attrCollection.Count == 0 ) return null; // create data table table = new DataTable(); bool primaryKeyFieldFound = false; foreach ( XmlAttribute attr in attrCollection ) { if (attr.Name == primaryKeyColumn) primaryKeyFieldFound = true; table.Columns.Add( attr.Name ); } if (!primaryKeyFieldFound) throw new Exception("Unable to set primary key in datatable because field '"+primaryKeyColumn+"'was not found."); table.PrimaryKey = new DataColumn[] {table.Columns[primaryKeyColumn]}; if (autoIncrement) { table.Columns[primaryKeyColumn].AutoIncrement = true; table.Columns[primaryKeyColumn].AutoIncrementStep = 1; } // add rows DataRow row = null; foreach ( XmlNode n in nodelist ) { row = table.NewRow(); foreach ( XmlAttribute a in n.Attributes ) { row[a.Name] = a.Value; } table.Rows.Add( row ); } table.AcceptChanges(); return table; }
private void button2_Click(object sender, EventArgs e) { //bool okxml; d = new XmlDocument(); openFileDialog1.Title = "Dechide fisier Xml"; openFileDialog1.Filter = "Fisiere Xml(*.xml)|*.xml|Toate Tipurile(*.*)|*.*"; openFileDialog1.FileName = ""; if (openFileDialog1.ShowDialog() == DialogResult.OK) { adr = openFileDialog1.FileName; } if (adr != null) { try { d.Load(adr); okxml = true; } catch { MessageBox.Show("Va rugam incarcati un fisier .xml"); } if (okxml == true) { try { pacient = d.SelectNodes("Pacient"); XmlNode nume = pacient.Item(0).SelectSingleNode("nume"); numeTextBox1.Text = nume.InnerText; XmlNode cnp = pacient.Item(0).SelectSingleNode("cnp"); cNPTextBox3.Text = cnp.InnerText; XmlNode sex = pacient.Item(0).SelectSingleNode("sex"); sexComboBox.Text = sex.InnerText; XmlNode ocup = pacient.Item(0).SelectSingleNode("ocupatie"); ocupatieTextBox.Text = ocup.InnerText; XmlNode dzp = pacient.Item(0).SelectSingleNode("dzp"); dZPComboBox.Text = dzp.InnerText; XmlNode dzf = pacient.Item(0).SelectSingleNode("dzf"); dZFComboBox.Text = dzf.InnerText; XmlNode bolicardio = pacient.Item(0).SelectSingleNode("bolicardio"); boliCardioComboBox.Text = bolicardio.InnerText; XmlNode hafam = pacient.Item(0).SelectSingleNode("hafam"); hAFamComboBox.Text = hafam.InnerText; XmlNode dislip = pacient.Item(0).SelectSingleNode("dislip"); dislipidemieComboBox.Text = dislip.InnerText; XmlNode obez = pacient.Item(0).SelectSingleNode("obez"); obezitateComboBox.Text = obez.InnerText; XmlNode msubite = pacient.Item(0).SelectSingleNode("msubite"); mortiSubiteComboBox.Text = msubite.InnerText; XmlNode cmacro = pacient.Item(0).SelectSingleNode("cmacro"); copilMacroComboBox.Text = cmacro.InnerText; XmlNode diabetg = pacient.Item(0).SelectSingleNode("diabetg"); diabetGComboBox.Text = diabetg.InnerText; XmlNode cardioischemica = pacient.Item(0).SelectSingleNode("cardioischemica"); cardioIschemicaComboBox.Text = cardioischemica.InnerText; XmlNode hapers = pacient.Item(0).SelectSingleNode("hapers"); hAPersComboBox.Text = hapers.InnerText; XmlNode imavc = pacient.Item(0).SelectSingleNode("imavc"); iMAVCComboBox.Text = imavc.InnerText; XmlNode stlglucoza = pacient.Item(0).SelectSingleNode("stlglucoza"); sTGlucozaComboBox.Text = stlglucoza.InnerText; XmlNode fumat = pacient.Item(0).SelectSingleNode("fumat"); fumatComboBox.Text = fumat.InnerText; XmlNode nrtigari = pacient.Item(0).SelectSingleNode("nrtigari"); nrtigarTextBox2.Text = nrtigari.InnerText; XmlNode act = pacient.Item(0).SelectSingleNode("act"); actFizicaComboBox.Text = act.InnerText; XmlNode g = pacient.Item(0).SelectSingleNode("g"); gTextBoxa2.Text = g.InnerText; XmlNode h = pacient.Item(0).SelectSingleNode("h"); hTextBox2.Text = h.InnerText; XmlNode ca = pacient.Item(0).SelectSingleNode("ca"); caTextBox3.Text = ca.InnerText; XmlNode tas = pacient.Item(0).SelectSingleNode("tas"); taSistolicaTextBox2.Text = tas.InnerText; XmlNode tad = pacient.Item(0).SelectSingleNode("tad"); taDiastolicaTextBox2.Text = tad.InnerText; XmlNode glic = pacient.Item(0).SelectSingleNode("glic"); glicemieTextBox2.Text = glic.InnerText; XmlNode hdl = pacient.Item(0).SelectSingleNode("hdl"); hDLColTextBox2.Text = hdl.InnerText; XmlNode ldl = pacient.Item(0).SelectSingleNode("ldl"); lDLColTextBox2.Text = ldl.InnerText; XmlNode tg = pacient.Item(0).SelectSingleNode("tg"); tgTextBox3.Text = tg.InnerText; XmlNode data = pacient.Item(0).SelectSingleNode("data"); dateTextBox2.Text = data.InnerText; adr = null; } catch { MessageBox.Show("Va rugam incarcati un document valid."); } } } }
void LoadFavorites(XmlNodeList list) { for(int i = 0; i < list.Count; i++) { if(list.Item(i).Name == "Favorite") AddFavoriteItem(list[i].InnerText, list[i].Attributes[0].Value, true); } ChangeFavorites(true); }
void LoadLinks(XmlNodeList list) { for(int i = 0; i < list.Count; i++) { if(list.Item(i).Name == "Link") AddNewItem(list[i].InnerText); } }
private void CreateRegistrationParameters(CodeExpressionCollection methodParameters, XmlNodeList scriptParameters) { CodeExpression[] initializers = new CodeExpression[scriptParameters.Count]; for (int i = 0; i < scriptParameters.Count; i++) { if (scriptParameters.Item(i) is XmlElement) { XmlElement element = (XmlElement) scriptParameters.Item(i); if (PARAMETER.Equals(element.Name)) { string key = element.GetAttribute(KEY); if (key != null && key.Length != 0) { initializers[i] = new CodeObjectCreateExpression( typeof (ComponentParameter), new CodeExpression[] {new CodePrimitiveExpression(key)}); } else if (element.Value != null && element.Value.Length != 0) { initializers[i] = new CodeObjectCreateExpression( typeof (ConstantParameter), new CodeExpression[] {new CodeTypeOfExpression(element.Value)}); } else { throw new PicoCompositionException("Parameter not set"); } } } } methodParameters.Add(new CodeArrayCreateExpression( "IParameter", initializers)); }
public static void refreshAirplanes(List<Airplane> loadedAirplanes) { try { PlaneDocument.Load(@"Simulation\schedule.xml"); } catch (FileNotFoundException) { return; } rawPlaneSchedule = PlaneDocument.GetElementsByTagName("plane"); Assembly assembly = Assembly.Load("Introductieproject"); int planeCount = rawPlaneSchedule.Count; for (int i = 0; i < planeCount; i++) { XmlNode rawAirplane = rawPlaneSchedule.Item(i); XmlAttributeCollection attr = rawAirplane.Attributes; String registration = attr["registration"].Value; String flight = attr["flight"].Value; String type = attr["type"].Value; String carrier = attr["carrier"].Value; String gate = attr["gate"].Value; String landingDate = attr["landingDate"].Value; String arrivalDate = attr["arrivalDate"].Value; String departureDate = attr["departureDate"].Value; String origin = attr["origin"].Value; String destination = attr["destination"].Value; String location = attr["location"].Value; DateTime landingDateTime = DateTime.Parse(landingDate); DateTime arrivalDateTime = DateTime.Parse(arrivalDate); DateTime departureDateTime = DateTime.Parse(departureDate); //Split landinglocation string to double[] location. string[] coords = location.Split(','); double[] landingLocation = new double[2]; landingLocation[0] = double.Parse(coords[0]); landingLocation[1] = double.Parse(coords[1]); bool airplaneAlreadyLoaded = false; foreach (Airplane currentAirplane in loadedAirplanes) { if (currentAirplane.Registration == null) { continue; } if (currentAirplane.Registration.Equals(registration)) // Airplane bestaat al { currentAirplane.flight = flight; currentAirplane.carrier = carrier; currentAirplane.landingDate = landingDateTime; currentAirplane.arrivalDate = arrivalDateTime; currentAirplane.departureDate = departureDateTime; currentAirplane.origin = origin; currentAirplane.destination = destination; airplaneAlreadyLoaded = true; break; } } if (!airplaneAlreadyLoaded && TimeKeeper.currentSimTime < arrivalDateTime) { System.Type objectType = assembly.GetType("Introductieproject.Objects." + type); Airplane newAirplane = (Airplane)Activator.CreateInstance(objectType); newAirplane.setXMLVariables(landingLocation, landingDateTime, gate, arrivalDateTime, departureDateTime, registration, flight, carrier, origin, destination); loadedAirplanes.Add(newAirplane); } } }
private static object ProcessNodeList(QueryNode.LispProcessingContext owner, XmlNodeList nodeList) { if (nodeList.Count == 0) return null; else if (nodeList.Count == 1) { XmlNode node = nodeList.Item(0); if (node is XmlElement) if (node.ChildNodes.Count == 1 && node.FirstChild is XmlText) return XmlDataAccessor.Convert(XmlDataAccessor.GetNodeType(node, XmlDataAccessor.GetTypeManager(owner.Node)), node); else return node; else return node.Value; } return nodeList; }
public static DataTable xmlNodeListToTable(XmlNodeList xmlNodeList, string tableName, bool autoDictionary) { DataTable dt = new DataTable(tableName); string colName = ""; int ColumnsCount = 0; XmlNode tableDefinitionNode = xmlNodeList.Item(xmlNodeList.Count - 1); // Considering the last node to have more attributes. if (tableDefinitionNode == null) return null; foreach (XmlAttribute colDefNode in tableDefinitionNode.Attributes) { colName = colDefNode.Name; DataColumn dc = new DataColumn(colName, System.Type.GetType("System.String")); dt.Columns.Add(dc); ColumnsCount++; } for (int i = 0; i < xmlNodeList.Count; i++) { DataRow dr = dt.NewRow(); string curValue = ""; for (int j = 0; j < ColumnsCount; j++) { try { curValue = xmlNodeList.Item(i).Attributes[j].Value; dr[j] = curValue; } catch (Exception) { continue; } } dt.Rows.Add(dr); } return dt; }
public void LerRSS(string URL) { try { objBD = new bd(); RSS = WebRequest.Create(URL); RSS_Retorno = RSS.GetResponse(); RSS_Stream = RSS_Retorno.GetResponseStream(); XML = new XmlDocument(); XML.Load(RSS_Stream); XML_Itens = XML.SelectNodes("rss/channel/item"); TituloRSS = ""; LinkRSS = ""; DataRSS = ""; TotalItens = XML_Itens.Count; if (TotalItens > 10) { TotalItens = 10; } for (i = 0; i < TotalItens; i++) { rsResultado = XML_Itens.Item(i).SelectSingleNode("title"); if (rsResultado != null) { TituloRSS = rsResultado.InnerText; } else { TituloRSS = ""; } rsResultado = XML_Itens.Item(i).SelectSingleNode("link"); if (rsResultado != null) { LinkRSS = rsResultado.InnerText; } else { LinkRSS = ""; } rsResultado = XML_Itens.Item(i).SelectSingleNode("pubDate"); if (rsResultado != null) { DataRSS = rsResultado.InnerText; if (DataRSS.Length > 0) { DataRSS = Convert.ToDateTime(DataRSS).ToString(); } } else { DataRSS = ""; } objBD.ExecutaSQL("EXEC sp_fmera_atualiza_noticias '" + TituloRSS + "','" + LinkRSS + "','" + DataRSS + "','',3"); } } catch { throw; } }
private static void CheckImplicitMods(IList<StaticMod> mods, XmlNodeList modList) { Assert.IsNotNull(modList); Assert.AreEqual(mods.Count(), modList.Count); for (int i = 0; i < mods.Count(); i++) { var modNode = modList.Item(i); Assert.IsNotNull(modNode); var attribs = modNode.Attributes; Assert.IsNotNull(attribs); var modName = attribs.GetNamedItem(SrmDocument.ATTR.modification_name).Value; Assert.AreEqual(mods[i].Name, modName); } }
/// ----------------------------------------------------------------------------- /// <summary>s /// Converts a list of Xml nodes to a DataTable. /// </summary> /// <param name="nodelist">List of Xml nodes</param> /// <returns>DataTable</returns> /// <remarks> /// This method convert /// </remarks> /// ----------------------------------------------------------------------------- public static DataTable GetDataTable( XmlNodeList nodelist ) { DataTable table = null; XmlNode node = null; if ( nodelist == null ) return null; // get parameter names node = nodelist.Item( 0 ); if ( node == null ) return null; XmlAttributeCollection attrCollection = node.Attributes; if ( attrCollection == null ) return null; if ( attrCollection.Count == 0 ) return null; // create data table table = new DataTable(); foreach ( XmlAttribute attr in attrCollection ) { table.Columns.Add( attr.Name ); } // add rows DataRow row = null; foreach ( XmlNode n in nodelist ) { row = table.NewRow(); foreach ( XmlAttribute a in n.Attributes ) { row[a.Name] = a.Value; } table.Rows.Add( row ); } table.AcceptChanges(); return table; }
private DataTable ConvertXmlNodeListToDataTable(XmlNodeList xnl) { DataTable dt = new DataTable(); int TempColumn = 0; // Add dynamic columns foreach (XmlNode parentNode in xnl) { foreach (XmlNode node in parentNode.ChildNodes) { TempColumn++; DataColumn dc = new DataColumn(node.Name, Type.GetType("System.String")); if (!dt.Columns.Contains(node.Name)) { dt.Columns.Add(dc); } } } // Add static columns DataColumn dcSelf = new DataColumn("this", Type.GetType("System.String")); dt.Columns.Add(dcSelf); DataColumn dcElementName = new DataColumn("ElementName", Type.GetType("System.String")); dt.Columns.Add(dcElementName); DataColumn dcPageNodeID = new DataColumn("PageNodeID", Type.GetType("System.String")); dt.Columns.Add(dcPageNodeID); // Add content int ColumnsCount = dt.Columns.Count; for (int i = 0; i < xnl.Count; i++) { DataRow dr = dt.NewRow(); for (int j = 0; j < ColumnsCount; j++) { if (xnl.Item(i).ChildNodes[j] != null) dr[xnl.Item(i).ChildNodes[j].Name] = Globals.RemoveCDATA(xnl.Item(i).ChildNodes[j].InnerXml); } // Add static content dr["this"] = Globals.RemoveCDATA(xnl.Item(i).InnerXml); dr["ElementName"] = xnl.Item(i).Name; dr["PageNodeID"] = this.PageNodeID; dt.Rows.Add(dr); } return dt; }
// This method gets the name value pair based on the first two attributes of every node public static NameValueCollection GetNameValuePair( XmlNodeList nodeList ) { NameValueCollection nameVal = new NameValueCollection(); if ( nodeList == null ) return null; // get parameter names XmlNode node = nodeList.Item( 0 ); if ( node == null ) return null; XmlAttributeCollection attrCollection = node.Attributes; if ( attrCollection == null ) return null; if ( attrCollection.Count < 2 ) return null; string attrName1 = null, attrName2 = null; // read all nodes in nodelist and extract first two attributes foreach ( XmlNode n in nodeList ) { attrName1 = n.Attributes[0].Value; attrName2 = n.Attributes[1].Value; nameVal.Add( attrName1, attrName2 ); } return nameVal; }
private void UpdateBlocks(XmlDocument doc, XmlNodeList levelData) { //Delete blocks foreach (string[] deletedBlock in editor.deletedBlocks) { foreach (XmlNode block in levelData.Item(0)) { if (block.Name.CompareTo("tile") == 0) { XmlAttribute attributePosX = block.Attributes["posX"]; XmlAttribute attributePosZ = block.Attributes["posZ"]; if (attributePosX.Value.CompareTo(deletedBlock[0]) == 0 && attributePosZ.Value.CompareTo(deletedBlock[1]) == 0) { levelData.Item(0).RemoveChild(block); } } } } //Add blocks foreach (string[] newBlock in editor.newBlocks) { XmlNode nuevo = doc.CreateNode(XmlNodeType.Element, "tile", ""); ((XmlElement)nuevo).SetAttribute("posX", newBlock[0]); ((XmlElement)nuevo).SetAttribute("posZ", newBlock[1]); levelData.Item(0).AppendChild(nuevo); } }
private void UpdateEnemies(XmlDocument doc, XmlNodeList levelData) { //Delete enemies foreach (string[] deletedEnemy in editor.deletedEnemies) { foreach (XmlNode enemy in levelData.Item(3)) { if (enemy.Name.CompareTo("tile") == 0) { XmlAttribute attributeType = enemy.Attributes["type"]; XmlAttribute attributePosX = enemy.Attributes["posX"]; XmlAttribute attributePosZ = enemy.Attributes["posZ"]; if (attributeType.Value.CompareTo(deletedEnemy[0]) == 0 && attributePosX.Value.CompareTo(deletedEnemy[1]) == 0 && attributePosZ.Value.CompareTo(deletedEnemy[2]) == 0) { levelData.Item(2).RemoveChild(enemy); } } } } //Add enemies foreach (string[] newEnemy in editor.newEnemies) { XmlNode nuevo = doc.CreateNode(XmlNodeType.Element, "tile", ""); ((XmlElement)nuevo).SetAttribute("type", newEnemy[0]); ((XmlElement)nuevo).SetAttribute("posX", newEnemy[1]); ((XmlElement)nuevo).SetAttribute("posZ", newEnemy[2]); levelData.Item(2).AppendChild(nuevo); } }
private void UpdatePowerUps(XmlDocument doc, XmlNodeList levelData) { //Delete powerUp foreach (string[] deletedPowerUp in editor.deletedPowerUps) { foreach (XmlNode powerUp in levelData.Item(1)) { if (powerUp.Name.CompareTo("tile") == 0) { XmlAttribute attributeType = powerUp.Attributes["type"]; XmlAttribute attributePosX = powerUp.Attributes["posX"]; XmlAttribute attributePosZ = powerUp.Attributes["posZ"]; if (attributeType.Value.CompareTo(deletedPowerUp[0]) == 0 && attributePosX.Value.CompareTo(deletedPowerUp[1]) == 0 && attributePosZ.Value.CompareTo(deletedPowerUp[2]) == 0) { levelData.Item(1).RemoveChild(powerUp); } } } } //Add powerUp foreach (string[] newPowerUp in editor.newPowerUps) { XmlNode nuevo = doc.CreateNode(XmlNodeType.Element, "tile", ""); ((XmlElement)nuevo).SetAttribute("type", newPowerUp[0]); ((XmlElement)nuevo).SetAttribute("posX", newPowerUp[1]); ((XmlElement)nuevo).SetAttribute("posZ", newPowerUp[2]); levelData.Item(1).AppendChild(nuevo); } }
/// <summary> /// Reusable functions /// </summary> private void ParseSearchResults(XmlNodeList ndList, XmlNamespaceManager xnManager, int indexCatalog) { for (int i = 0; i < ndList.Count; i++) { XmlNode ndMDa = ndList.Item(i); switch (indexCatalog) { case 0: ListDataModel aasgModel = ParseEachGeoportalSearchResult(ndMDa, xnManager); Add2DaList(aasgModel); break; case 1: ListDataModel onegeologyModel = ParseEachOnegeologySearchResult(ndMDa, xnManager); Add2DaList(onegeologyModel); break; case 2: ListDataModel geogovModel = ParseEachMultiDistGeoportalSearchResult(ndMDa, xnManager); Add2DaList(geogovModel); break; case 3: ListDataModel usginModel = ParseEachMultiDistGeoportalSearchResult(ndMDa, xnManager); Add2DaList(usginModel); break; } } }
public static DataTable xmlNodeListToTable(XmlNodeList xmlNodeList, string tableName, DictionaryEntry colValPair) { DataTable dt = new DataTable(tableName); string colName = ""; // Creating Columns and Table XmlNode tableDefinitionNode = xmlNodeList.Item(0); if (tableDefinitionNode == null) return null; foreach (XmlNode colDefNode in tableDefinitionNode.ChildNodes) { if (colValPair.Key == null) { colName = colDefNode.Name; //colValPair.Key = "id"; //colValPair.Value = colName; } else { colName = getNodeAttributeValue(colDefNode, colValPair.Key.ToString()); } DataColumn dc = new DataColumn(colName, System.Type.GetType("System.String")); dt.Columns.Add(dc); } int ColumnsCount = dt.Columns.Count; for (int i = 0; i < xmlNodeList.Count; i++) { DataRow dr = dt.NewRow(); string curValue = ""; for (int j = 0; j < ColumnsCount; j++) { if (colValPair.Value == null) { colName = dt.Columns[j].ColumnName; } else { colName = colValPair.Value.ToString(); } curValue = getNodeAttributeValue(xmlNodeList.Item(i).ChildNodes[j], colName); if (j == 6 || j == 7) { dr[j] = attachClickEvent(curValue); } else { dr[j] = curValue; } } dt.Rows.Add(dr); } return dt; }