System.Xml.XmlNode.AppendChild(System.Xml.XmlNode)

Here are the examples of the csharp api System.Xml.XmlNode.AppendChild(System.Xml.XmlNode) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

954 Examples 7

19 Source : HandlingEditor.cs
with MIT License
from carmineos

private XmlDoreplacedent GetXmlFromPreset(HandlingPreset preset)
        {
            XmlDoreplacedent doc = new XmlDoreplacedent();
            XmlElement handlingItem = doc.CreateElement("Item");
            handlingItem.SetAttribute("type", "CHandlingData");

            foreach (var item in preset.Fields)
            {
                string fieldName = item.Key;
                dynamic fieldValue = item.Value;
                XmlElement field = doc.CreateElement(fieldName);

                Type fieldType = HandlingInfo.FieldsInfo[fieldName].Type;
                if(fieldType == FieldType.FloatType)
                {
                    var value = (float)fieldValue;
                    field.SetAttribute("value", value.ToString());
                }
                else if (fieldType == FieldType.IntType)
                {
                    var value = (int)fieldValue;
                    field.SetAttribute("value", value.ToString());
                }
                else if (fieldType == FieldType.Vector3Type)
                {
                    var value = (Vector3)(fieldValue);
                    field.SetAttribute("x", value.X.ToString());
                    field.SetAttribute("y", value.Y.ToString());
                    field.SetAttribute("z", value.Z.ToString());
                }
                else if (fieldType == FieldType.StringType)
                {
                    field.InnerText = fieldValue;
                }
                else
                {

                }
                handlingItem.AppendChild(field);
            }
            doc.AppendChild(handlingItem);

            return doc;
        }

19 Source : manager.cs
with BSD 2-Clause "Simplified" License
from chengse66

internal void save()
		{
			XmlDoreplacedent doreplacedent = new XmlDoreplacedent();
			XmlElement element = doreplacedent.CreateElement("momiji");

			foreach (res_character character in characters.Values)
				character.save(element, doreplacedent);

			foreach (res_item item in items.Values)
				item.save(element, doreplacedent);

			doreplacedent.AppendChild(doreplacedent.CreateXmlDeclaration("1.0", "utf-8", "yes"));
			doreplacedent.AppendChild(element);

			doreplacedent.Save(components);
		}

19 Source : manager.cs
with BSD 2-Clause "Simplified" License
from chengse66

internal new void save(XmlNode host, XmlDoreplacedent doreplacedent)
		{
			XmlElement element = doreplacedent.CreateElement("character");

			element.Attributes.Append(generate_attribute("location", location, doreplacedent));

			save_items(element, doreplacedent);

			for (int index = 0; index < properties.Length - 1; ++index)
				(properties[index] as res_objects).save(element, doreplacedent);

			host.AppendChild(element);
		}

19 Source : manager.cs
with BSD 2-Clause "Simplified" License
from chengse66

internal void save(XmlNode host, XmlDoreplacedent doreplacedent)
		{
			XmlElement element = doreplacedent.CreateElement("item");

			element.Attributes.Append(generate_attribute("location", location, doreplacedent));

			for (int index = 0; index < properties.Length - 1; ++index)
				(properties[index] as res_objects).save(element, doreplacedent);

			host.AppendChild(element);
		}

19 Source : manager.cs
with BSD 2-Clause "Simplified" License
from chengse66

internal void save(XmlNode host, XmlDoreplacedent doreplacedent)
		{
			XmlElement element = doreplacedent.CreateElement(name);

			save_items(element, doreplacedent);

			host.AppendChild(element);
		}

19 Source : manager.cs
with BSD 2-Clause "Simplified" License
from chengse66

internal void save(XmlNode host, XmlDoreplacedent doreplacedent)
		{
			XmlElement element = doreplacedent.CreateElement("object");

			element.Attributes.Append(generate_attribute("type", type, doreplacedent));
			element.Attributes.Append(generate_attribute("id", idenreplacedy, doreplacedent));
			element.Attributes.Append(generate_attribute("name", name, doreplacedent));
			element.Attributes.Append(generate_attribute("level", level, doreplacedent));
			element.Attributes.Append(generate_attribute("gender", gender, doreplacedent));
			element.Attributes.Append(generate_attribute("cash", cash, doreplacedent));
			element.Attributes.Append(generate_attribute("job", job, doreplacedent));
			element.Attributes.Append(generate_attribute("etc", etc, doreplacedent));

			host.AppendChild(element);
		}

19 Source : GameGenieDataBase.cs
with GNU General Public License v3.0
from ClusterM

public void AddCode(GameGenieCode ACode)
        {
            FModified = true;

            XmlNode lCodeNode = FXml.CreateElement("gamegenie");
            GameNode.AppendChild(lCodeNode);

            XmlAttribute lAttribute;

            lAttribute = FXml.CreateAttribute("code");
            lAttribute.Value = ACode.Code.ToUpper().Trim();
            lCodeNode.Attributes.Append(lAttribute);

            lAttribute = FXml.CreateAttribute("description");
            lAttribute.Value = ACode.Description;
            lCodeNode.Attributes.Append(lAttribute);

            if (FGameCodes == null)
                FGameCodes = new List<GameGenieCode>();

            FGameCodes.Add(ACode);
        }

19 Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM

private string TreeToXml()
        {
            var root = treeView.Nodes[0];
            var xml = new XmlDoreplacedent();
            var treeNode = xml.CreateElement("Tree");
            xml.AppendChild(treeNode);
            NodeToXml(xml, treeNode, root);
            using (var stringWriter = new StringWriter())
            using (var xmlTextWriter = new XmlTextWriter(stringWriter))
            {
                xmlTextWriter.Formatting = Formatting.Indented;
                xmlTextWriter.WriteStartDoreplacedent();
                xml.WriteTo(xmlTextWriter);
                xmlTextWriter.WriteEndDoreplacedent();
                xmlTextWriter.Flush();
                return stringWriter.GetStringBuilder().ToString();
            }
        }

19 Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM

private void NodeToXml(XmlDoreplacedent xml, XmlElement element, TreeNode node)
        {
            foreach (TreeNode child in node.Nodes)
            {
                if (child.Tag is NesMenuFolder)
                {
                    var subElement = xml.CreateElement("Folder");
                    var folder = child.Tag as NesMenuFolder;
                    subElement.SetAttribute("name", folder.Name);
                    subElement.SetAttribute("icon", folder.ImageId);
                    subElement.SetAttribute("position", ((byte)folder.Position).ToString());
                    element.AppendChild(subElement);
                    NodeToXml(xml, subElement, child);
                }
                else if (child.Tag is NesMiniApplication)
                {
                    var subElement = xml.CreateElement("Game");
                    var game = child.Tag as NesMiniApplication;
                    subElement.SetAttribute("code", game.Code);
                    subElement.SetAttribute("name", game.Name);
                    element.AppendChild(subElement);
                }
                else if (child.Tag is NesDefaultGame)
                {
                    var subElement = xml.CreateElement("OriginalGame");
                    var game = child.Tag as NesDefaultGame;
                    subElement.SetAttribute("code", game.Code);
                    subElement.SetAttribute("name", game.Name);
                    element.AppendChild(subElement);
                }
            }
        }

19 Source : GameGenieDataBase.cs
with GNU General Public License v3.0
from ClusterM

public void ImportCodes(string AFileName, bool AQuiet = false)
        {
            if (File.Exists(AFileName))
            {
                XmlDoreplacedent lXml = new XmlDoreplacedent();
                XmlNodeList lCodes = null;
                XmlNode lCodeNode = null;
                XmlAttribute lAttribute = null;

                lXml.Load(AFileName);
                lCodes = lXml.SelectNodes("//genie/..");

                FModified = true;

                XmlNode lDeleteNode = GameNode.FirstChild;
                while (lDeleteNode != null)
                {
                    GameNode.RemoveChild(GameNode.FirstChild);
                    lDeleteNode = GameNode.FirstChild;
                }
                GameCodes.Clear();

                string lGameFileName = Path.Combine(Path.Combine(Path.Combine(Program.BaseDirectoryExternal, "games"), FGame.Code), FGame.Code + ".nes");
                foreach (XmlNode lCurCode in lCodes)
                {
                    NesFile lGame = new NesFile(lGameFileName);
                    try
                    {
                        lGame.PRG = GameGeniePatcherNes.Patch(lGame.PRG, lCurCode["genie"].InnerText);

                        lCodeNode = FXml.CreateElement("gamegenie");
                        GameNode.AppendChild(lCodeNode);

                        lAttribute = FXml.CreateAttribute("code");
                        lAttribute.Value = lCurCode["genie"].InnerText.ToUpper().Trim();
                        lCodeNode.Attributes.Append(lAttribute);

                        lAttribute = FXml.CreateAttribute("description");
                        lAttribute.Value = lCurCode["description"].InnerText;
                        lCodeNode.Attributes.Append(lAttribute);

                        GameCodes.Add(new GameGenieCode(lCurCode["genie"].InnerText.ToUpper().Trim(), lCurCode["description"].InnerText));
                    }
                    catch (GameGenieFormatException)
                    {
                        if (!AQuiet)
                            MessageBox.Show(string.Format(Resources.GameGenieFormatError, lCurCode["genie"].InnerText, FGame.Name), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    catch (GameGenieNotFoundException)
                    {
                        if (!AQuiet)
                            MessageBox.Show(string.Format(Resources.GameGenieNotFound, lCurCode["genie"].InnerText, FGame.Name), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

19 Source : CompilationDatabaseSettings.cs
with Apache License 2.0
from CoatiSoftware

public XmlNode GetMetaDataXML(XmlDoreplacedent doc)
		{
			// XmlDoreplacedent doc = new XmlDoreplacedent();
			XmlNode root = doc.CreateElement("cdb");

			XmlElement name = doc.CreateElement("name");
			name.InnerText = _name;

			XmlElement sourceProject = doc.CreateElement("sourceProject");
			sourceProject.InnerText = _sourceProject;

			XmlElement directory = doc.CreateElement("directory");
			directory.InnerText = _directory;

			XmlElement lastUpdated = doc.CreateElement("lastUpdated");
			lastUpdated.InnerText = _lastUpdated.ToString();

			XmlElement includedProjects = doc.CreateElement("includedProjects");
			foreach (string project in _includedProjects)
			{
				XmlElement includedProject = doc.CreateElement("includedProject");
				includedProject.InnerText = project;
				includedProjects.AppendChild(includedProject);
			}

			XmlElement configuration = doc.CreateElement("configuration");
			configuration.InnerText = _configurationName;

			XmlElement platform = doc.CreateElement("platform");
			platform.InnerText = _platformName;

			XmlElement additionalClangOptions = doc.CreateElement("additionalClangOptions");
			additionalClangOptions.InnerText = _additionalClangOptions;

			XmlElement nonSystemIncludesUseAngleBrackets = doc.CreateElement("nonSystemIncludesUseAngleBrackets");
			nonSystemIncludesUseAngleBrackets.InnerText = _nonSystemIncludesUseAngleBrackets.ToString();

			root.AppendChild(name);
			root.AppendChild(sourceProject);
			root.AppendChild(directory);
			root.AppendChild(lastUpdated);
			root.AppendChild(includedProjects);
			root.AppendChild(configuration);
			root.AppendChild(platform);
			root.AppendChild(additionalClangOptions);
			root.AppendChild(nonSystemIncludesUseAngleBrackets);

			return root;
		}

19 Source : CompilationDatabaseSettingsList.cs
with Apache License 2.0
from CoatiSoftware

public void SaveMetaData()
		{
			try
			{
				XmlDoreplacedent doc = new XmlDoreplacedent();
				XmlNode root = doc.CreateElement("cdbs");

				foreach (CompilationDatabaseSettings cdb in _settings)
				{
					XmlNode metaData = cdb.GetMetaDataXML(doc);

					root.AppendChild(metaData);
				}

				System.IO.StringWriter writer = new System.IO.StringWriter();

				XmlSerializer serializer = new XmlSerializer(typeof(XmlElement));
				serializer.Serialize(writer, root);

				DataUtility.GetInstance().ClearData();
				DataUtility.GetInstance().AppendData(writer.ToString());
			}
			catch(Exception e)
			{
				Logging.Logging.LogError("Failed to save meta data: " + e.Message);
			}
		}

19 Source : XDCMake.cs
with zlib License
from codecat

static void Main(string[] args)
	{
		var inputFiles = new List<string>();
		var outputFile = string.Empty;
		var replacedemblyName = string.Empty;

		foreach (var arg in args)
		{
			if (arg.Length < 2)
			{
				continue;
			}

			if (arg[0] == '@')
			{
				ProcessStartInfo startInfo = new ProcessStartInfo();
				startInfo.FileName = replacedembly.GetExecutingreplacedembly().Location;
				startInfo.Arguments = File.ReadAllText(arg.Substring(1));
				startInfo.UseShellExecute = false;
				startInfo.RedirectStandardOutput = true;

				Process process = Process.Start(startInfo);
				Console.Write(process.StandardOutput.ReadToEnd());
				process.WaitForExit();
				return;
			}

			if (arg[0] != '/' && arg[0] != '-')
			{
				replacedemblyName = arg;
				continue;
			}

			string id = arg.Substring(1);
			string param = string.Empty;

			if (id[0] == 'F')
			{
				if (id.Length > 2)
				{
					param = id.Substring(2);
					id = id.Substring(0, 2);
				}
			}

			switch (id)
			{
				case "Fs":
					inputFiles.Add(param);
					break;
				case "Fo":
					outputFile = param;
					break;
			}
		}

		if (outputFile.Length == 0)
		{
			Console.WriteLine("error XDC0007 : No output file specified");
			return;
		}

		if (replacedemblyName.Length == 0)
		{
			replacedemblyName = Path.GetFileNameWithoutExtension(outputFile);
		}

		var outputDoreplacedent = new XmlDoreplacedent();
		outputDoreplacedent.LoadXml("<doc><replacedembly>" + replacedemblyName + "</replacedembly><members/></doc>");
		XmlNode outputNode = outputDoreplacedent.DoreplacedentElement.SelectSingleNode("members");

		foreach (var file in inputFiles)
		{
			var doc = new XmlDoreplacedent();

			try
			{
				doc.Load(file);
			}
			catch (Exception)
			{
				Console.WriteLine(file + " : warning XDC0004 : Unable to load XML fragment");
				continue;
			}

			XmlNode members = doc.SelectSingleNode("doc/members");

			if (members == null)
			{
				Console.WriteLine(file + " : warning XDC0022 : File contains no <doc><members> tag");
				continue;
			}

			foreach (XmlNode member in members.ChildNodes)
			{
				member.Attributes.RemoveNamedItem("decl");
				member.Attributes.RemoveNamedItem("source");
				member.Attributes.RemoveNamedItem("line");

				outputNode.AppendChild(outputDoreplacedent.ImportNode(member, true));
			}
		}

		try
		{
			outputDoreplacedent.Save(outputFile);
		}
		catch (Exception)
		{
			Console.WriteLine("error XDC0002 : Cannot write to output file");
		}
	}

19 Source : BookmarkManagerMemento.cs
with MIT License
from codewitch-honey-crisis

public XmlElement ToXmlElement(XmlDoreplacedent doc)
		{
			XmlElement bookmarknode  = doc.CreateElement("Bookmarks");
			
			foreach (int line in bookmarks) {
				XmlElement markNode = doc.CreateElement("Mark");
				
				XmlAttribute lineAttr = doc.CreateAttribute("line");
				lineAttr.InnerText = line.ToString();
				markNode.Attributes.Append(lineAttr);
						
				bookmarknode.AppendChild(markNode);
			}
			
			return bookmarknode;
		}

19 Source : main.cs
with GNU General Public License v3.0
from CommentViewerCollection

public void Write()
        {
            if (!Options.IsEnabled || _commentCollection.Count == 0)
                return;

            //TODO:各ファイルが存在しなかった時のエラー表示
            if (string.IsNullOrEmpty(CommentXmlPath) && IsHcgSettingFileExists())
            {
                var hcgPath = GetHcgPath(Options.HcgSettingFilePath);
                CommentXmlPath = hcgPath + "\\comment.xml";
                //TODO:パスがxmlファイルで無かった場合の対応。ディレクトリの可能性も。
            }
            if (!File.Exists(CommentXmlPath))
            {
                var doc = new XmlDoreplacedent();
                var root = doc.CreateElement("log");

                doc.AppendChild(root);
                doc.Save(CommentXmlPath);
            }
            XElement xml;
            try
            {
                xml = XElement.Load(CommentXmlPath);
            }
            catch (IOException ex)
            {
                //being used in another process
                Debug.WriteLine(ex.Message);
                return;
            }
            catch (XmlException)
            {
                //Root element is missing.
                xml = new XElement("log");
            }
            lock (_lockObj)
            {
                var arr = _commentCollection.ToArray();

                foreach (var data in arr)
                {
                    var item = new XElement("comment", data.Comment);
                    item.SetAttributeValue("no", "0");
                    item.SetAttributeValue("time", ToUnixTime(GetCurrentDateTime()));
                    item.SetAttributeValue("owner", 0);
                    item.SetAttributeValue("service", data.SiteName);
                    //2019/08/25 コメジェネの仕様で、handleタグが無いと"0コメ"に置換されてしまう。だから空欄でも良いからhandleタグは必須。
                    var handle = string.IsNullOrEmpty(data.Nickname) ? "" : data.Nickname;
                    item.SetAttributeValue("handle", handle);
                    xml.Add(item);
                }
                try
                {
                    WriteXml(xml, CommentXmlPath);
                }
                catch (IOException ex)
                {
                    //コメントの流れが早すぎるとused in another processが来てしまう。
                    //この場合、コメントが書き込まれずに消されてしまう。
                    Debug.WriteLine(ex.Message);
                    return;
                }
                _commentCollection.Clear();
            }
        }

19 Source : demoWeiXinApi.cs
with MIT License
from comsmobiler

public string CreateRequestXML(SortedDictionary<string, string> requestDict)
        {
            XmlDoreplacedent doc = new XmlDoreplacedent();
            XmlElement xmlNode = doc.CreateElement("xml");
            var props = this.GetType().GetProperties();
            //signDictList主要用于生成签名,详见 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=4_3
            var signDictList = new List<string>();
            foreach (var pop in requestDict)
            {
                if (string.IsNullOrEmpty(pop.Value) == false)
                {
                    XmlElement element = doc.CreateElement(pop.Key);
                    element.InnerText = pop.Value;
                    xmlNode.AppendChild(element);
                    signDictList.Add(pop.Key + "=" + element.InnerText);
                }
            }
            //使用MD5生成签字算法
            signDictList.Add("key=" + key);
            string signTempStr = string.Join("&", signDictList);
            var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            string signStr = BitConverter.ToString(md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signTempStr))).Replace("-", "");
            XmlElement sign = doc.CreateElement("sign");
            sign.InnerText = signStr;
            xmlNode.AppendChild(sign);

            doc.AppendChild(xmlNode);
            return doc.OuterXml;
        }

19 Source : XmlNodeConverter.cs
with MIT License
from CragonGame

public IXmlNode AppendChild(IXmlNode newChild)
    {
      XmlNodeWrapper xmlNodeWrapper = (XmlNodeWrapper) newChild;
      _node.AppendChild(xmlNodeWrapper._node);

      return newChild;
    }

19 Source : GridToXmlSerializer.cs
with MIT License
from craigbridges

public XmlDoreplacedent Serialize
            (
                IDataGrid grid
            )
        {
            if (grid == null)
            {
                return new XmlDoreplacedent();
            }

            var doreplacedent = new XmlDoreplacedent();

            // The XML declaration is recommended, but not mandatory
            var xmlDeclaration = doreplacedent.CreateXmlDeclaration
            (
                "1.0",
                "UTF-8",
                null
            );
            
            var rootNode = doreplacedent.CreateElement
            (
                "DataGrid"
            );

            doreplacedent.InsertBefore
            (
                xmlDeclaration,
                doreplacedent.DoreplacedentElement
            );

            foreach (var row in grid)
            {
                var rowNode = doreplacedent.CreateElement
                (
                    "Item"
                );

                foreach (var cell in row)
                {
                    // Get a string representation of the cells value
                    var value = 
                    (
                        cell.Value == null ? String.Empty : cell.Value.ToString()
                    );

                    // Create the cell node and append it to the row node
                    var cellNode = doreplacedent.CreateElement
                    (
                        cell.Key
                    );

                    cellNode.InnerText = value;
                    rowNode.AppendChild(cellNode);
                }

                rootNode.AppendChild(rowNode);
            }

            doreplacedent.AppendChild(rootNode);

            return doreplacedent;
        }

19 Source : VersionHelper.cs
with MIT License
from CslaGenFork

private static void Convert405To406()
        {
            var newFileVersion = "4.0.6";

            var xmlFile = string.Empty;
            for (var index = 1; index < FileLines.Length; index++)
            {
                var line = FileLines[index];
                xmlFile += line;
            }

            XmlDoreplacedent xDoc = new XmlDoreplacedent();
            xDoc.PreserveWhitespace = true;
            xDoc.LoadXml(xmlFile);
            XmlElement root = xDoc.DoreplacedentElement;

            XmlNodeList cslaObjects = root.SelectNodes("//CslaObjects");
            if (cslaObjects != null)
            {
                foreach (XmlNode cslaObject in cslaObjects)
                {
                    XmlNodeList parameters = cslaObject.SelectNodes("//LoadParameters/Parameter");
                    if (parameters != null)
                    {
                        for (var index = 0; index < parameters.Count; index++)
                        {
                            XmlNode newParameter = HandleParameter(xDoc, parameters[index]);
                            XmlNode parentNode = parameters[index].ParentNode;
                            parameters[index].ParentNode.RemoveChild(parameters[index]);
                            parentNode.AppendChild(newParameter);
                        }
                    }
                }
            }

            XmlNodeList replacedociativeEnreplacedies = root.SelectNodes("//replacedociativeEnreplacedies");
            if (replacedociativeEnreplacedies != null)
            {
                foreach (XmlNode replacedociativeEnreplacedy in replacedociativeEnreplacedies)
                {
                    XmlNodeList parameters = replacedociativeEnreplacedy.SelectNodes("//MainLoadParameters/Parameter");
                    if (parameters != null)
                    {
                        for (var index = 0; index < parameters.Count; index++)
                        {
                            XmlNode newParameter = HandleParameter(xDoc, parameters[index]);
                            XmlNode parentNode = parameters[index].ParentNode;
                            parameters[index].ParentNode.RemoveChild(parameters[index]);
                            parentNode.AppendChild(newParameter);
                        }
                    }

                    parameters = replacedociativeEnreplacedy.SelectNodes("//SecondaryLoadParameters/Parameter");
                    if (parameters != null)
                    {
                        for (var index = 0; index < parameters.Count; index++)
                        {
                            XmlNode newParameter = HandleParameter(xDoc, parameters[index]);
                            XmlNode parentNode = parameters[index].ParentNode;
                            parameters[index].ParentNode.RemoveChild(parameters[index]);
                            parentNode.AppendChild(newParameter);
                        }
                    }
                }
            }

            var firstline = FileLines[0];
            FileLines = new[] {firstline, xDoc.InnerXml};

            for (var index = 0; index < FileLines.Length; index++)
            {
                FileLines[index] = FileLines[index].Replace(@"<FileVersion>" + _fileVersionFound + "</FileVersion>",
                    @"<FileVersion>" + newFileVersion + "</FileVersion>");
            }

            _fileVersionFound = newFileVersion;

            _forceSave = true;
        }

19 Source : VersionHelper.cs
with MIT License
from CslaGenFork

private static XmlNode HandleParameter(XmlDoreplacedent xDoc, XmlNode parameter)
        {
            XmlNodeList criteriaName = parameter.SelectNodes("./Criteria/Name");
            XmlNodeList propertyName = parameter.SelectNodes("./Property/ParameterName");
            XmlNode newParameter = xDoc.CreateNode(XmlNodeType.Element, "Parameter", string.Empty);

            for (var index = 0; index < criteriaName.Count; index++)
            {
                XmlNode newCriteria = xDoc.CreateNode(XmlNodeType.Element, "CriteriaName", string.Empty);
                newCriteria.InnerText = criteriaName[index].InnerText;
                newParameter.AppendChild(newCriteria);
            }

            for (var index = 0; index < criteriaName.Count; index++)
            {
                XmlNode newProperty = xDoc.CreateNode(XmlNodeType.Element, "PropertyName", string.Empty);
                newProperty.InnerText = propertyName[index].InnerText;
                newParameter.AppendChild(newProperty);
            }

            return newParameter;
        }

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void AddEmptyElement(XmlNode htmlEmptyElement)
		{
			var htmlParent = _openedElements.Peek();
			htmlParent.AppendChild(htmlEmptyElement);
		}

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void CloseElement(string htmlElementName)
		{
			if (_pendingInlineElements.Count > 0 && _pendingInlineElements.Peek().LocalName == htmlElementName)
			{
				var htmlInlineElement = _pendingInlineElements.Pop();
				var htmlParent = _openedElements.Peek();
				htmlParent.AppendChild(htmlInlineElement);
				return;
			}
		    if (!IsElementOpened(htmlElementName)) return;
		    while (_openedElements.Count > 1)
		    {
		        var htmlOpenedElement = _openedElements.Pop(); 
		        if (htmlOpenedElement.LocalName == htmlElementName) return; 
		        if (HtmlSchema.IsInlineElement(htmlOpenedElement.LocalName)) _pendingInlineElements.Push(CreateElementCopy(htmlOpenedElement));
		    }
		}

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void AddTextContent(string textContent)
		{
			OpenPendingInlineElements();

			var htmlParent = _openedElements.Peek();
			var textNode = _doreplacedent.CreateTextNode(textContent);
			htmlParent.AppendChild(textNode);
		}

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void AddComment(string comment)
		{
			OpenPendingInlineElements();

			var htmlParent = _openedElements.Peek();
			var xmlComment = _doreplacedent.CreateComment(comment);
			htmlParent.AppendChild(xmlComment);
		}

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void OpenPendingInlineElements()
		{
		    if (_pendingInlineElements.Count <= 0) return;
		    var htmlInlineElement = _pendingInlineElements.Pop();

		    OpenPendingInlineElements();

		    var htmlParent = _openedElements.Peek();
		    htmlParent.AppendChild(htmlInlineElement);
		    _openedElements.Push(htmlInlineElement);
		}

19 Source : HtmlParser.cs
with GNU General Public License v3.0
from cuellius

private void OpenStructuringElement(XmlElement htmlElement)
		{
			if (HtmlSchema.IsBlockElement(htmlElement.LocalName))
			{
				while (_openedElements.Count > 0 && HtmlSchema.IsInlineElement(_openedElements.Peek().LocalName))
				{
					var htmlInlineElement = _openedElements.Pop();
					_pendingInlineElements.Push(CreateElementCopy(htmlInlineElement));
				}
			}

			if (_openedElements.Count > 0)
			{
				var htmlParent = _openedElements.Peek();

				if (HtmlSchema.ClosesOnNextElementStart(htmlParent.LocalName, htmlElement.LocalName))
				{
					_openedElements.Pop();
					htmlParent = _openedElements.Count > 0 ? _openedElements.Peek() : null;
				}

			    htmlParent?.AppendChild(htmlElement);
			}

			_openedElements.Push(htmlElement);
		}

19 Source : BrushInfo.cs
with MIT License
from cwensley

public void WriteXml(XmlElement element)
		{
			if (encoding != null)
				element.SetAttribute("codepage", encoding.CodePage);
			foreach (var ch in characters)
			{
				var childElement = element.OwnerDoreplacedent.CreateElement("char");
				childElement.SetAttribute("value", (int)ch.character);
				element.AppendChild(childElement);
			}
		}

19 Source : CharacterDocumentInfo.cs
with MIT License
from cwensley

public override void WriteXml(XmlElement element)
		{
			base.WriteXml(element);
			element.SetAttribute("use9x", use9x);
			element.SetAttribute("dosAspect", dosAspect);
			element.SetAttribute("iceColours", iceColours);
			element.SetAttribute("insertMode", insertMode);
			element.SetAttribute("shiftSelect", shiftSelect);
			element.WriteChildSizeXml("attribute-dialog", AttributeDialogSize);
			element.WriteChildRectangleXml("attribute-dialog-bounds", AttributeDialogBounds);

			element.WriteChildListXml(brushes, "brush", "brushes");

			XmlElement charElement = element.OwnerDoreplacedent.CreateElement("characterSets");
			for (int set = 0; set < characterSets.GetLength(0); set++)
			{
				XmlElement charSet = charElement.OwnerDoreplacedent.CreateElement("characterSet");
				charSet.SetAttribute("set", set.ToString());

				for (int i = 0; i < characterSets.GetLength(1); i++)
				{
					charSet.SetAttribute("f" + Convert.ToString(i + 1), characterSets[set, i].ToString());
				}

				charElement.AppendChild(charSet);
			}
			element.AppendChild(charElement);
		}

19 Source : DocumentInfo.cs
with MIT License
from cwensley

public virtual void WriteXml(XmlElement element)
		{
			if (!AutoScroll)
				element.SetAttribute ("autoscroll", AutoScroll);
			XmlElement formatsElement = element.OwnerDoreplacedent.CreateElement("formats");
			formats.WriteXml(formatsElement);
			element.AppendChild(formatsElement);
			XmlElement zoomInfoElement = element.OwnerDoreplacedent.CreateElement("zoomInfo");
			zoomInfo.WriteXml(zoomInfoElement);
			element.AppendChild(zoomInfoElement);
		}

19 Source : DocumentInfo.cs
with MIT License
from cwensley

public void WriteXml(XmlElement element)
		{
			foreach (DoreplacedentInfo info in Values)
			{
				XmlElement infoElement = element.OwnerDoreplacedent.CreateElement("doreplacedentInfo");
				infoElement.SetAttribute("infoId", info.ID);
				info.WriteXml(infoElement);
				
				element.AppendChild(infoElement);
			}
		}

19 Source : Format.cs
with MIT License
from cwensley

public void WriteXml (XmlElement element)
        {
            foreach (Format info in this.Values) {
                XmlElement infoElement = element.OwnerDoreplacedent.CreateElement ("formatInfo");
                infoElement.SetAttribute ("infoId", info.ID);
                info.WriteXml (infoElement);
             
                element.AppendChild (infoElement);
            }
        }

19 Source : Main.cs
with MIT License
from cwensley

public void WriteXml()
        {
            try
            {
                if (EditMode)
                    Settings.EditFileSplit = splitter.Position;
                else
                    Settings.FileSplit = splitter.Position;


                var doc = new XmlDoreplacedent();
                var head = doc.CreateElement("pablo");

                Settings.WriteXml(head);


                var elem = doc.CreateElement("main");
                if (FileList.CurrentDirectory != null)
                {
                    var dir = FileList.CurrentDirectory;
                    while (dir is VirtualDirectoryInfo)
                    {
                        var file = ((VirtualDirectoryInfo)dir).FileInfo;
                        if (file == null)
                            break;
                        dir = file.Directory;
                    }
                    elem.SetAttribute("path", dir.FullName);
                }
                head.AppendChild(elem);

                head.WriteChildXml("main-window", new WindowStateSaver(this));


                doc.AppendChild(head);
                doc.Save(SettingsFile);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error! {0}", ex);
            }

        }

19 Source : XmlExtensions.cs
with MIT License
from cwensley

public static void WriteChildXml<T>(this XmlElement element, string childElementName, T child)
			where T : IXmlReadable
		{
			if (EqualityComparer<T>.Default.Equals(child, default(T))) return;
			var childElement = element.OwnerDoreplacedent.CreateElement(childElementName);
			child.WriteXml(childElement);
			element.AppendChild(childElement);
		}

19 Source : XmlExtensions.cs
with MIT License
from cwensley

public static void WriteChildListXml<T>(this XmlElement element, IEnumerable<T> list, string childElement, string listElement = null)
			where T : IXmlReadable
		{
			XmlElement listNode = (!string.IsNullOrEmpty(listElement)) ? element.OwnerDoreplacedent.CreateElement(listElement) : element;

			foreach (T child in list)
			{
				if (!EqualityComparer<T>.Default.Equals(child, default(T)))
				{
					var childNode = element.OwnerDoreplacedent.CreateElement(childElement);
					child.WriteXml(childNode);
					listNode.AppendChild(childNode);
				}
			}

			if (listNode != element && !listNode.IsEmpty)
			{
				element.AppendChild(listNode);
			}
		}

19 Source : XmlExtensions.cs
with MIT License
from cwensley

public static void SaveXml(this IXmlReadable obj, Stream stream, string doreplacedentElementName = "object")
		{
			var doc = new XmlDoreplacedent();
			var topNode = doc.CreateElement(doreplacedentElementName);
			obj.WriteXml(topNode);
			doc.AppendChild(topNode);
			doc.Save(stream);
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddBreak(XmlElement xamlParentElement, string htmlElementName)
		{
			// Create new xaml element corresponding to this html element
			XmlElement xamlLineBreak = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/HtmlToXamlConverter.Xaml_LineBreak, _xamlNamespace);
			xamlParentElement.AppendChild(xamlLineBreak);
			if (htmlElementName == "hr")
			{
				XmlText xamlHorizontalLine = xamlParentElement.OwnerDoreplacedent.CreateTextNode("----------------------");
				xamlParentElement.AppendChild(xamlHorizontalLine);
				xamlLineBreak = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/HtmlToXamlConverter.Xaml_LineBreak, _xamlNamespace);
				xamlParentElement.AppendChild(xamlLineBreak);
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static XmlNode AddImplicitParagraph(XmlElement xamlParentElement, XmlNode htmlNode, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Collect all non-block elements and wrap them into implicit Paragraph
			XmlElement xamlParagraph = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/HtmlToXamlConverter.Xaml_Paragraph, _xamlNamespace);
			XmlNode lastNodeProcessed = null;
			while (htmlNode != null)
			{
				if (htmlNode is XmlComment)
				{
					DefineInlineFragmentParent((XmlComment)htmlNode, /*xamlParentElement:*/null);
				}
				else if (htmlNode is XmlText)
				{
					if (htmlNode.Value.Trim().Length > 0)
					{
						AddTextRun(xamlParagraph, htmlNode.Value);
					}
				}
				else if (htmlNode is XmlElement)
				{
					string htmlChildName = ((XmlElement)htmlNode).LocalName.ToLower();
					if (HtmlSchema.IsBlockElement(htmlChildName))
					{
						// The sequence of non-blocked inlines ended. Stop implicit loop here.
						break;
					}
					else
					{
						AddInline(xamlParagraph, (XmlElement)htmlNode, inheritedProperties, stylesheet, sourceContext);
					}
				}

				// Store last processed node to return it at the end
				lastNodeProcessed = htmlNode;
				htmlNode = htmlNode.NextSibling;
			}

			// Add the Paragraph to the parent
			// If only whitespaces and commens have been encountered,
			// then we have nothing to add in implicit paragraph; forget it.
			if (xamlParagraph.FirstChild != null)
			{
				xamlParentElement.AppendChild(xamlParagraph);
			}

			// Need to return last processed node
			return lastNodeProcessed;
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddSpanOrRun(XmlElement xamlParentElement, XmlElement htmlElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Decide what XAML element to use for this inline element.
			// Check whether it contains any nested inlines
			bool elementHasChildren = false;
			for (XmlNode htmlNode = htmlElement.FirstChild; htmlNode != null; htmlNode = htmlNode.NextSibling)
			{
				if (htmlNode is XmlElement)
				{
					string htmlChildName = ((XmlElement)htmlNode).LocalName.ToLower();
					if (HtmlSchema.IsInlineElement(htmlChildName) || HtmlSchema.IsBlockElement(htmlChildName) ||
							htmlChildName == "img" || htmlChildName == "br" || htmlChildName == "hr")
					{
						elementHasChildren = true;
						break;
					}
				}
			}

			string xamlElementName = elementHasChildren ? HtmlToXamlConverter.Xaml_Span : HtmlToXamlConverter.Xaml_Run;

			// Create currentProperties as a compilation of local and inheritedProperties, set localProperties
			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			// Create a XAML element corresponding to this html element
			XmlElement xamlElement = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/xamlElementName, _xamlNamespace);
			ApplyLocalProperties(xamlElement, localProperties, /*isBlock:*/false);

			// Recurse into element subtree
			for (XmlNode htmlChildNode = htmlElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
			{
				AddInline(xamlElement, htmlChildNode, currentProperties, stylesheet, sourceContext);
			}

			// Add the new element to the parent.
			xamlParentElement.AppendChild(xamlElement);
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddTextRun(XmlElement xamlElement, string textData)
		{
			// Remove control characters
			for (int i = 0; i < textData.Length; i++)
			{
				if (Char.IsControl(textData[i]))
				{
					textData = textData.Remove(i--, 1);  // decrement i to compensate for character removal
				}
			}

			// Replace No-Breaks by spaces (160 is a code of   enreplacedy in html)
			//  This is a work around since WPF/XAML does not support  .
			textData = textData.Replace((char)160, ' ');

			if (textData.Length > 0)
			{
				xamlElement.AppendChild(xamlElement.OwnerDoreplacedent.CreateTextNode(textData));
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddHyperlink(XmlElement xamlParentElement, XmlElement htmlElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Convert href attribute into NavigateUri and TargetName
			string href = GetAttribute(htmlElement, "href");
			if (href == null)
			{
				// When href attribute is missing - ignore the hyperlink
				AddSpanOrRun(xamlParentElement, htmlElement, inheritedProperties, stylesheet, sourceContext);
			}
			else
			{
				// Create currentProperties as a compilation of local and inheritedProperties, set localProperties
				Hashtable localProperties;
				Hashtable currentProperties = GetElementProperties(htmlElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

				// Create a XAML element corresponding to this html element
				XmlElement xamlElement = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/HtmlToXamlConverter.Xaml_Hyperlink, _xamlNamespace);
				ApplyLocalProperties(xamlElement, localProperties, /*isBlock:*/false);

				string[] hrefParts = href.Split(new char[] { '#' });
				if (hrefParts.Length > 0 && hrefParts[0].Trim().Length > 0)
				{
					xamlElement.SetAttribute(HtmlToXamlConverter.Xaml_Hyperlink_NavigateUri, hrefParts[0].Trim());
				}
				if (hrefParts.Length == 2 && hrefParts[1].Trim().Length > 0)
				{
					xamlElement.SetAttribute(HtmlToXamlConverter.Xaml_Hyperlink_TargetName, hrefParts[1].Trim());
				}

				// Recurse into element subtree
				for (XmlNode htmlChildNode = htmlElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
				{
					AddInline(xamlElement, htmlChildNode, currentProperties, stylesheet, sourceContext);
				}

				// Add the new element to the parent.
				xamlParentElement.AppendChild(xamlElement);
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddList(XmlElement xamlParentElement, XmlElement htmlListElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			string htmlListElementName = htmlListElement.LocalName.ToLower();

			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlListElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			// Create Xaml List element
			XmlElement xamlListElement = xamlParentElement.OwnerDoreplacedent.CreateElement(null, Xaml_List, _xamlNamespace);

			// Set default list markers
			if (htmlListElementName == "ol")
			{
				// Ordered list
				xamlListElement.SetAttribute(HtmlToXamlConverter.Xaml_List_MarkerStyle, Xaml_List_MarkerStyle_Decimal);
			}
			else
			{
				// Unordered list - all elements other than OL treated as unordered lists
				xamlListElement.SetAttribute(HtmlToXamlConverter.Xaml_List_MarkerStyle, Xaml_List_MarkerStyle_Disc);
			}

			// Apply local properties to list to set marker attribute if specified
			// TODO: Should we have separate list attribute processing function?
			ApplyLocalProperties(xamlListElement, localProperties, /*isBlock:*/true);

			// Recurse into list subtree
			for (XmlNode htmlChildNode = htmlListElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
			{
				if (htmlChildNode is XmlElement && htmlChildNode.LocalName.ToLower() == "li")
				{
					sourceContext.Add((XmlElement)htmlChildNode);
					AddLisreplacedem(xamlListElement, (XmlElement)htmlChildNode, currentProperties, stylesheet, sourceContext);
					Debug.replacedert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == htmlChildNode);
					sourceContext.RemoveAt(sourceContext.Count - 1);
				}
				else
				{
					// Not an li element. Add it to previous ListBoxItem
					//  We need to append the content to the end
					// of a previous list item.
				}
			}

			// Add the List element to xaml tree - if it is not empty
			if (xamlListElement.HasChildNodes)
			{
				xamlParentElement.AppendChild(xamlListElement);
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddLisreplacedem(XmlElement xamlListElement, XmlElement htmlLIElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Parameter validation
			Debug.replacedert(xamlListElement != null);
			Debug.replacedert(xamlListElement.LocalName == Xaml_List);
			Debug.replacedert(htmlLIElement != null);
			Debug.replacedert(htmlLIElement.LocalName.ToLower() == "li");
			Debug.replacedert(inheritedProperties != null);

			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlLIElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			XmlElement xamlLisreplacedemElement = xamlListElement.OwnerDoreplacedent.CreateElement(null, Xaml_Lisreplacedem, _xamlNamespace);

			// TODO: process local properties for li element

			// Process children of the Lisreplacedem
			for (XmlNode htmlChildNode = htmlLIElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode != null ? htmlChildNode.NextSibling : null)
			{
				htmlChildNode = AddBlock(xamlLisreplacedemElement, htmlChildNode, currentProperties, stylesheet, sourceContext);
			}

			// Add resulting ListBoxItem to a xaml parent
			xamlListElement.AppendChild(xamlLisreplacedemElement);
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddColumnInformation(XmlElement htmlTableElement, XmlElement xamlTableElement, ArrayList columnStartsAllRows, Hashtable currentProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Add column information
			if (columnStartsAllRows != null)
			{
				// We have consistent information derived from table cells; use it
				// The last element in columnStarts represents the end of the table
				for (int columnIndex = 0; columnIndex < columnStartsAllRows.Count - 1; columnIndex++)
				{
					XmlElement xamlColumnElement;

					xamlColumnElement = xamlTableElement.OwnerDoreplacedent.CreateElement(null, Xaml_TableColumn, _xamlNamespace);
					xamlColumnElement.SetAttribute(Xaml_Width, ((double)columnStartsAllRows[columnIndex + 1] - (double)columnStartsAllRows[columnIndex]).ToString());
					xamlTableElement.AppendChild(xamlColumnElement);
				}
			}
			else
			{
				// We do not have consistent information from table cells;
				// Translate blindly colgroups from html.                
				for (XmlNode htmlChildNode = htmlTableElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
				{
					if (htmlChildNode.LocalName.ToLower() == "colgroup")
					{
						// TODO: add column width information to this function as a parameter and process it
						AddTableColumnGroup(xamlTableElement, (XmlElement)htmlChildNode, currentProperties, stylesheet, sourceContext);
					}
					else if (htmlChildNode.LocalName.ToLower() == "col")
					{
						AddTableColumn(xamlTableElement, (XmlElement)htmlChildNode, currentProperties, stylesheet, sourceContext);
					}
					else if (htmlChildNode is XmlElement)
					{
						// Some element which belongs to table body. Stop column loop.
						break;
					}
				}
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static XmlNode AddTableCellsToTableRow(XmlElement xamlTableRowElement, XmlNode htmlTDStartNode, Hashtable currentProperties, ArrayList columnStarts, ArrayList activeRowSpans, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// parameter validation
			Debug.replacedert(xamlTableRowElement.LocalName == Xaml_TableRow);
			Debug.replacedert(currentProperties != null);
			if (columnStarts != null)
			{
				Debug.replacedert(activeRowSpans.Count == columnStarts.Count);
			}

			XmlNode htmlChildNode = htmlTDStartNode;
			double columnStart = 0;
			double columnWidth = 0;
			int columnIndex = 0;
			int columnSpan = 0;

			while (htmlChildNode != null && htmlChildNode.LocalName.ToLower() != "tr" && htmlChildNode.LocalName.ToLower() != "tbody" && htmlChildNode.LocalName.ToLower() != "thead" && htmlChildNode.LocalName.ToLower() != "tfoot")
			{
				if (htmlChildNode.LocalName.ToLower() == "td" || htmlChildNode.LocalName.ToLower() == "th")
				{
					XmlElement xamlTableCellElement = xamlTableRowElement.OwnerDoreplacedent.CreateElement(null, Xaml_TableCell, _xamlNamespace);

					sourceContext.Add((XmlElement)htmlChildNode);

					Hashtable tdElementLocalProperties;
					Hashtable tdElementCurrentProperties = GetElementProperties((XmlElement)htmlChildNode, currentProperties, out tdElementLocalProperties, stylesheet, sourceContext);

					// TODO: determine if localProperties can be used instead of htmlChildNode in this call, and if they can,
					// make necessary changes and use them instead.
					ApplyPropertiesToTableCellElement((XmlElement)htmlChildNode, xamlTableCellElement);

					if (columnStarts != null)
					{
						Debug.replacedert(columnIndex < columnStarts.Count - 1);
						while (columnIndex < activeRowSpans.Count && (int)activeRowSpans[columnIndex] > 0)
						{
							activeRowSpans[columnIndex] = (int)activeRowSpans[columnIndex] - 1;
							Debug.replacedert((int)activeRowSpans[columnIndex] >= 0);
							columnIndex++;
						}
						Debug.replacedert(columnIndex < columnStarts.Count - 1);
						columnStart = (double)columnStarts[columnIndex];
						columnWidth = GetColumnWidth((XmlElement)htmlChildNode);
						columnSpan = CalculateColumnSpan(columnIndex, columnWidth, columnStarts);
						int rowSpan = GetRowSpan((XmlElement)htmlChildNode);

						// Column cannot have no span
						Debug.replacedert(columnSpan > 0);
						Debug.replacedert(columnIndex + columnSpan < columnStarts.Count);

						xamlTableCellElement.SetAttribute(Xaml_TableCell_ColumnSpan, columnSpan.ToString());

						// Apply row span
						for (int spannedColumnIndex = columnIndex; spannedColumnIndex < columnIndex + columnSpan; spannedColumnIndex++)
						{
							Debug.replacedert(spannedColumnIndex < activeRowSpans.Count);
							activeRowSpans[spannedColumnIndex] = (rowSpan - 1);
							Debug.replacedert((int)activeRowSpans[spannedColumnIndex] >= 0);
						}

						columnIndex = columnIndex + columnSpan;
					}

					AddDataToTableCell(xamlTableCellElement, htmlChildNode.FirstChild, tdElementCurrentProperties, stylesheet, sourceContext);
					if (xamlTableCellElement.HasChildNodes)
					{
						xamlTableRowElement.AppendChild(xamlTableCellElement);
					}

					Debug.replacedert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == htmlChildNode);
					sourceContext.RemoveAt(sourceContext.Count - 1);

					htmlChildNode = htmlChildNode.NextSibling;
				}
				else
				{
					// Not td element. Ignore it.
					// TODO: Consider better recovery
					htmlChildNode = htmlChildNode.NextSibling;
				}
			}
			return htmlChildNode;
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddParagraph(XmlElement xamlParentElement, XmlElement htmlElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Create currentProperties as a compilation of local and inheritedProperties, set localProperties
			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			// Create a XAML element corresponding to this html element
			XmlElement xamlElement = xamlParentElement.OwnerDoreplacedent.CreateElement(/*prefix:*/null, /*localName:*/HtmlToXamlConverter.Xaml_Paragraph, _xamlNamespace);
			ApplyLocalProperties(xamlElement, localProperties, /*isBlock:*/true);

			// Recurse into element subtree
			for (XmlNode htmlChildNode = htmlElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
			{
				AddInline(xamlElement, htmlChildNode, currentProperties, stylesheet, sourceContext);
			}

			// Add the new element to the parent.
			xamlParentElement.AppendChild(xamlElement);
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static XmlElement AddOrphanLisreplacedems(XmlElement xamlParentElement, XmlElement htmlLIElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			Debug.replacedert(htmlLIElement.LocalName.ToLower() == "li");

			XmlElement lastProcessedLisreplacedemElement = null;

			// Find out the last element attached to the xamlParentElement, which is the previous sibling of this node
			XmlNode xamlLisreplacedemElementPreviousSibling = xamlParentElement.LastChild;
			XmlElement xamlListElement;
			if (xamlLisreplacedemElementPreviousSibling != null && xamlLisreplacedemElementPreviousSibling.LocalName == Xaml_List)
			{
				// Previously added Xaml element was a list. We will add the new li to it
				xamlListElement = (XmlElement)xamlLisreplacedemElementPreviousSibling;
			}
			else
			{
				// No list element near. Create our own.
				xamlListElement = xamlParentElement.OwnerDoreplacedent.CreateElement(null, Xaml_List, _xamlNamespace);
				xamlParentElement.AppendChild(xamlListElement);
			}

			XmlNode htmlChildNode = htmlLIElement;
			string htmlChildNodeName = htmlChildNode == null ? null : htmlChildNode.LocalName.ToLower();

			//  Current element properties missed here.
			//currentProperties = GetElementProperties(htmlLIElement, inheritedProperties, out localProperties, stylesheet);

			// Add li elements to the parent xamlListElement we created as long as they appear sequentially
			// Use properties inherited from xamlParentElement for context 
			while (htmlChildNode != null && htmlChildNodeName == "li")
			{
				AddLisreplacedem(xamlListElement, (XmlElement)htmlChildNode, inheritedProperties, stylesheet, sourceContext);
				lastProcessedLisreplacedemElement = (XmlElement)htmlChildNode;
				htmlChildNode = htmlChildNode.NextSibling;
				htmlChildNodeName = htmlChildNode == null ? null : htmlChildNode.LocalName.ToLower();
			}

			return lastProcessedLisreplacedemElement;
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddTable(XmlElement xamlParentElement, XmlElement htmlTableElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			// Parameter validation
			Debug.replacedert(htmlTableElement.LocalName.ToLower() == "table");
			Debug.replacedert(xamlParentElement != null);
			Debug.replacedert(inheritedProperties != null);

			// Create current properties to be used by children as inherited properties, set local properties
			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlTableElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			// TODO: process localProperties for tables to override defaults, decide cell spacing defaults

			// Check if the table contains only one cell - we want to take only its content
			XmlElement singleCell = GetCellFromSingleCellTable(htmlTableElement);

			if (singleCell != null)
			{
				//  Need to push skipped table elements onto sourceContext
				sourceContext.Add(singleCell);

				// Add the cell's content directly to parent
				for (XmlNode htmlChildNode = singleCell.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode != null ? htmlChildNode.NextSibling : null)
				{
					htmlChildNode = AddBlock(xamlParentElement, htmlChildNode, currentProperties, stylesheet, sourceContext);
				}

				Debug.replacedert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == singleCell);
				sourceContext.RemoveAt(sourceContext.Count - 1);
			}
			else
			{
				// Create xamlTableElement
				XmlElement xamlTableElement = xamlParentElement.OwnerDoreplacedent.CreateElement(null, Xaml_Table, _xamlNamespace);

				// replacedyze table structure for column widths and rowspan attributes
				ArrayList columnStarts = replacedyzeTableStructure(htmlTableElement, stylesheet);

				// Process COLGROUP & COL elements
				AddColumnInformation(htmlTableElement, xamlTableElement, columnStarts, currentProperties, stylesheet, sourceContext);

				// Process table body - TBODY and TR elements
				XmlNode htmlChildNode = htmlTableElement.FirstChild;

				while (htmlChildNode != null)
				{
					string htmlChildName = htmlChildNode.LocalName.ToLower();

					// Process the element
					if (htmlChildName == "tbody" || htmlChildName == "thead" || htmlChildName == "tfoot")
					{
						//  Add more special processing for TableHeader and TableFooter
						XmlElement xamlTableBodyElement = xamlTableElement.OwnerDoreplacedent.CreateElement(null, Xaml_TableRowGroup, _xamlNamespace);
						xamlTableElement.AppendChild(xamlTableBodyElement);

						sourceContext.Add((XmlElement)htmlChildNode);

						// Get properties of Html tbody element
						Hashtable tbodyElementLocalProperties;
						Hashtable tbodyElementCurrentProperties = GetElementProperties((XmlElement)htmlChildNode, currentProperties, out tbodyElementLocalProperties, stylesheet, sourceContext);
						// TODO: apply local properties for tbody

						// Process children of htmlChildNode, which is tbody, for tr elements
						AddTableRowsToTableBody(xamlTableBodyElement, htmlChildNode.FirstChild, tbodyElementCurrentProperties, columnStarts, stylesheet, sourceContext);
						if (xamlTableBodyElement.HasChildNodes)
						{
							xamlTableElement.AppendChild(xamlTableBodyElement);
							// else: if there is no TRs in this TBody, we simply ignore it
						}

						Debug.replacedert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == htmlChildNode);
						sourceContext.RemoveAt(sourceContext.Count - 1);

						htmlChildNode = htmlChildNode.NextSibling;
					}
					else if (htmlChildName == "tr")
					{
						// Tbody is not present, but tr element is present. Tr is wrapped in tbody
						XmlElement xamlTableBodyElement = xamlTableElement.OwnerDoreplacedent.CreateElement(null, Xaml_TableRowGroup, _xamlNamespace);

						// We use currentProperties of xamlTableElement when adding rows since the tbody element is artificially created and has 
						// no properties of its own

						htmlChildNode = AddTableRowsToTableBody(xamlTableBodyElement, htmlChildNode, currentProperties, columnStarts, stylesheet, sourceContext);
						if (xamlTableBodyElement.HasChildNodes)
						{
							xamlTableElement.AppendChild(xamlTableBodyElement);
						}
					}
					else
					{
						// Element is not tbody or tr. Ignore it.
						// TODO: add processing for thead, tfoot elements and recovery for td elements
						htmlChildNode = htmlChildNode.NextSibling;
					}
				}

				if (xamlTableElement.HasChildNodes)
				{
					xamlParentElement.AppendChild(xamlTableElement);
				}
			}
		}

19 Source : HtmlToXamlConverter.cs
with MIT License
from cyberark

private static void AddTableColumn(XmlElement xamlTableElement, XmlElement htmlColElement, Hashtable inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
		{
			Hashtable localProperties;
			Hashtable currentProperties = GetElementProperties(htmlColElement, inheritedProperties, out localProperties, stylesheet, sourceContext);

			XmlElement xamlTableColumnElement = xamlTableElement.OwnerDoreplacedent.CreateElement(null, Xaml_TableColumn, _xamlNamespace);

			// TODO: process local properties for TableColumn element

			// Col is an empty element, with no subtree 
			xamlTableElement.AppendChild(xamlTableColumnElement);
		}

19 Source : HtmlParser.cs
with MIT License
from cyberark

private void OpenStructuringElement(XmlElement htmlElement)
		{
			// Close all pending inline elements
			// All block elements are considered as delimiters for inline elements
			// which forces all inline elements to be closed and re-opened in the following
			// structural element (if any).
			// By doing that we guarantee that all inline elements appear only within most nested blocks
			if (HtmlSchema.IsBlockElement(htmlElement.LocalName))
			{
				while (_openedElements.Count > 0 && HtmlSchema.IsInlineElement(_openedElements.Peek().LocalName))
				{
					XmlElement htmlInlineElement = _openedElements.Pop();
					Invariantreplacedert(_openedElements.Count > 0, "OpenStructuringElement: stack of opened elements cannot become empty here");

					_pendingInlineElements.Push(CreateElementCopy(htmlInlineElement));
				}
			}

			// Add this block element to its parent
			if (_openedElements.Count > 0)
			{
				XmlElement htmlParent = _openedElements.Peek();

				// Check some known block elements for auto-closing (LI and P)
				if (HtmlSchema.ClosesOnNextElementStart(htmlParent.LocalName, htmlElement.LocalName))
				{
					_openedElements.Pop();
					htmlParent = _openedElements.Count > 0 ? _openedElements.Peek() : null;
				}

				if (htmlParent != null)
				{
					// NOTE:
					// Actually we never expect null - it would mean two top-level P or LI (without a parent).
					// In such weird case we will loose all paragraphs except the first one...
					htmlParent.AppendChild(htmlElement);
				}
			}

			// Push it onto a stack
			_openedElements.Push(htmlElement);
		}

19 Source : HtmlParser.cs
with MIT License
from cyberark

private void AddEmptyElement(XmlElement htmlEmptyElement)
		{
			Invariantreplacedert(_openedElements.Count > 0, "AddEmptyElement: Stack of opened elements cannot be empty, as we have at least one artificial root element");
			XmlElement htmlParent = _openedElements.Peek();
			htmlParent.AppendChild(htmlEmptyElement);
		}

See More Examples