xmldocument

Why does XmlDocument.GetElementById always return null?

不打扰是莪最后的温柔 提交于 2019-12-11 04:01:33
问题 I've got some XML (valid XHTML) that looks like this: <html> <head> <script type="text/javascript"> <![CDATA[ function change_header(){ document.getElementById("myHeader").innerHTML="Nice day!"; }]]> </script> </head> <body> <h1 id="myHeader">Hello World!</h1> <button onclick="change_header()">Change text</button> </body> </html> And I'm trying to get the #myHeader node using docment.GetElementById("myHeader") but it always returns null . Why? I'm guessing it doesn't recognize the id

XML - How to grab child nodes in single node and not whole document?

≯℡__Kan透↙ 提交于 2019-12-11 03:29:33
问题 Been looking around for an answer and cant find anything - Im quite new so maybe Im not hitting up the right key words? This is a sample of the XML I am working with <database> <book> <title>A</title> <author> <name>1</name> </author> </book> <book> <title>B</title> <author> <name>2</name> </author> <author> <name>3</name> </author> <author> <name>4</name> </author> <author> <name>5</name> </author> </book> </database> Im trying to use C# XMLDocument to grab for book A author 1 and then for

Memory consumption when using Delphi7 COM interfaces in a multithreaded way

℡╲_俬逩灬. 提交于 2019-12-10 14:46:05
问题 It seems that there is some memory problem in Delphi7 when accessing COM object interfaces such as IXMLDocument and IXMLNode - and so forth - in a multithreaded way. Other COM interfaces may share this problem, but my "research" isn't that deep cause I have to proceed my current project as well. Creating TXMLDocument and manipulating it via interfaces like IXMLDocument and IXMLNode on a single thread is ok, but in a multithreading approach, when one thread creates the TXMLDocument object and

XmlDocument Save keeps file open

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 12:40:59
问题 I have a simple c# function that creates a basic XML file and saves: private void CreateXMlFile(string Filename, string Name, string Company) { XmlDocument doc = new XmlDocument(); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(docNode); XmlNode licenseNode = doc.CreateElement("license"); doc.AppendChild(licenseNode); XmlNode node = doc.CreateElement("Name"); node.AppendChild(doc.CreateTextNode(Name)); licenseNode.AppendChild(node); node = doc.CreateElement(

Force XmlDocument to save empty elements with an explicit closing tag

主宰稳场 提交于 2019-12-10 11:20:45
问题 I have the following code: string PathName = "C:\\Users\\TestUser\\Documents\\Project"; string FileName = "settings.xml"; XmlDocument Settings = new XmlDocument(); Settings.Load(Path.Combine(PathName, FileName)); XmlNode KnowledgeNode = Settings.SelectSingleNode("/Config/Map/Knowledge"); XmlNode UsersNode = Settings.CreateNode(XmlNodeType.Element, "Users", null); XmlAttribute FileDirectory = Settings.CreateAttribute("FileDirectory"); FileDirectory.Value = UserSelectedFileDirectory; UsersNode

How to use clipboard to copy data from Excel Sheet to DataTable?

五迷三道 提交于 2019-12-10 06:36:41
问题 I have a Winform project, created on Microsoft Framework 3.5. The users may have installed Windows 7 or Windows XP, and Office 2007 or above. I'm working on in a procedure to get the clipboard data and put in on a C# DataTable. I already created a method to get the raw data from the clipboard and upload it in a DataTable. But in some cases, the Excel data shows a value, but internally have another: I'm investigating a method to get the raw data from Excel: string XmlFmt = "XML Spreadsheet";

How to remove encoding=“UTF-8” standalone=“no” from xml Document object in Java

独自空忆成欢 提交于 2019-12-09 16:51:57
问题 I want to create XML in Java. DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); but Java automatically creates declaration like this <?xml version="1.0" encoding="UTF-8" standalone="no"?> How can I remove encoding="UTF-8" standalone="no" so it will be <?xml version="1.0"?> Thanks! 回答1: I think there is no legal way to exclude theese attributes from generation. But

Reading the Stack Overflow RSS feed

妖精的绣舞 提交于 2019-12-09 14:05:47
问题 I'm trying to get a list of unanswered questions from the feed, but I am having trouble reading it. const string RECENT_QUESTIONS = "https://stackoverflow.com/feeds"; XmlTextReader reader; XmlDocument doc; // Load the feed in reader = new XmlTextReader(RECENT_QUESTIONS); //reader.MoveToContent(); // Add the feed to the document doc = new XmlDocument(); doc.Load(reader); // Get the <feed> element XmlNodeList feed = doc.GetElementsByTagName("feed"); // Loop through each item under feed and add

Is there a way to manage changes to an irregular XML document like there is with DataTable?

妖精的绣舞 提交于 2019-12-09 13:29:42
问题 I'm looking for a way to import and export a list of changes to an XML data document (irregular structure; not naturally fitting a DataSet). If I had a regular structure I would use a DataTable, and I could evaluate which records have been edited and then commit or cancel the changes, and I could also transmit a packet of the required changes. How do I do this with XML data? If a good answer isn't available I'm thinking my best bet would be to use a DataTable with the scheme [XPath, Value]

Error :- The XmlReader state should be Interactive on XDocument.Load

送分小仙女□ 提交于 2019-12-08 15:07:19
问题 I get the following error :- System.InvalidOperationException: The XmlReader state should be Interactive. at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) in the following code. Could anybody point me what I doing wrong here? static XDocument GetContentAsXDocument(string xmlData) { XmlDocument xmlDocument = new XmlDocument(); if (!string.IsNullOrEmpty(xmlData)) { xmlDocument.LoadXml(xmlData);