xmldocument

String greater, less, and equal comparison in XmlDocument

纵饮孤独 提交于 2019-11-28 10:04:57
问题 i'm trying to do a string comparison in a XmlDocument, and the following is what i tried. I am wondering why the first 2 yield the right result, and the last 2 doesn't return any result. What i was trying to do is to filter out nodes based on a datetime string. Like the last example i have. thanks, XmlNodeList test = x2PathDoc.SelectNodes("//config /pendingversion [@versionconfigid > 1002002]"); XmlNodeList test2 = x2PathDoc.SelectNodes("//config /pendingversion [@versionconfigid >'1002002']"

Read a 'fake' xml document (xml fragment) in a XmlTextReader object

我的未来我决定 提交于 2019-11-28 10:03:59
问题 [Case] I have reveived a bunch of 'xml files' with metadata about a big number of documents in them. At least, that was what I requested. What I received where 'xml files' without a root element, they are structured something like this (i left out a bunch of elements): <folder name = "abc"></folder> <folder name = "abc/def"> <document name = "ghi1"> </document> <document name = "ghi2"> </document> </folder> [Problem] When I try to read the file in an XmlTextReader object it fails telling me

How to create a XmlDocument using XmlWriter in .NET?

与世无争的帅哥 提交于 2019-11-28 04:38:42
Many .NET functions use XmlWriter to output/generate xml. Outputting to a file/string/memory is a very operation: XmlWriter xw = XmlWriter.Create(PutYourStreamFileWriterEtcHere); xw.WriteStartElement("root"); ... Sometimes , you need to manipulate the resulting Xml and would therefore like to load it into a XmlDocument or might need an XmlDocument for some other reason but you must generate the XML using an XmlWriter. For example, if you call a function in a 3rd party library that outputs to a XmlWriter only. One of the things you can do is write the xml to a string and then load it into your

How to programmatically modify assemblyBinding in app.config?

≯℡__Kan透↙ 提交于 2019-11-28 03:04:58
问题 I am trying to change the bindingRedirect element at install time by using the XmlDocument class and modifying the value directly. Here is what my app.config looks like: <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> ... </sectionGroup> </configSections> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

using xmldocument to read xml

百般思念 提交于 2019-11-28 01:37:03
问题 <?xml version="1.0" encoding="utf-8" ?> <testcase> <date>4/12/13</date> <name>Mrinal</name> <subject>xmlTest</subject> </testcase> I am trying to read the above xml using c#, But i get null exception in the try catch block can any body suggest the required change. static void Main(string[] args) { XmlDocument xd = new XmlDocument(); xd.Load("C:/Users/mkumar/Documents/testcase.xml"); XmlNodeList nodelist = xd.SelectNodes("/testcase"); // get all <testcase> nodes foreach (XmlNode node in

How to add xmlnamespace to a xmldocument

会有一股神秘感。 提交于 2019-11-28 00:50:05
Im trying to create a xml the should look like this <?xml version="1.0" encoding="iso-8859-1"?> <MyTestSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Tests> <Test> <messaure>1</messaure> <height>4</height> </Test> <Test> <messaure>4</messaure> <height>53</height> </Test> </Tests> </MyTestSet> Its not a problem to create the Tests or Test elements, but what is the best way to Create the "MyTestSet" including the namespaces? Im using c# XMLDocument This works for me: XmlDocument.DocumentElement.SetAttribute("xmlns:xsi", "http://www.w3.org

Performance: XDocument versus XmlDocument

社会主义新天地 提交于 2019-11-27 23:31:51
I have read a comparison between the two here . This is primarily a question of performance, relating to both memory and speed. I've got several XML documents that are upwards of 100 - 300 K in size. I've noticed that there is some lag when loading this information into an XDocument rather than an XmlDocument object. Is there a serious performance difference between these two objects? Do they access the content of the XML differently? When working with a string of XML, which is preferred, or is there a difference? The end use of these object is to run queries ( XPath or LINQ, depending) on the

How to get XML with header (<?xml version=“1.0”…)?

≯℡__Kan透↙ 提交于 2019-11-27 22:50:00
Consider the following simple code which creates an XML document and displays it. XmlDocument xml = new XmlDocument(); XmlElement root = xml.CreateElement("root"); xml.AppendChild(root); XmlComment comment = xml.CreateComment("Comment"); root.AppendChild(comment); textBox1.Text = xml.OuterXml; it displays, as expected: <root><!--Comment--></root> It doesn't, however, display the <?xml version="1.0" encoding="UTF-8"?> So how can I get that as well? Create an XML-declaration using XmlDocument.CreateXmlDeclaration Method : XmlNode docNode = xml.CreateXmlDeclaration("1.0", "UTF-8", null); xml

How to remove all comment tags from XmlDocument

核能气质少年 提交于 2019-11-27 22:46:30
How would i go about to remove all comment tags from a XmlDocument instance? Is there a better way than retrieving a XmlNodeList and iterate over those? XmlNodeList list = xmlDoc.SelectNodes("//comment()"); foreach(XmlNode node in list) { node.ParentNode.RemoveChild(node); } When you load the xml, you can use XmlReaderSettings XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; XmlReader reader = XmlReader.Create("...", settings); xmlDoc.Load(reader); On an existing instance, your solution looks good. Nope thats about it, although I'd be inclind to place the

How do I get the entire XML string from a XMLDocument returned by jQuery (cross browser)?

旧巷老猫 提交于 2019-11-27 21:01:05
I have tried and failed to find out how to get the entire XML string from the XMLDocument returned by a GET. There are a lot of questions on SO on how to find or replace specific elements in the object, but I can't seem to find any answer to how to get the entire document as a string. The example I'm working with is from here . The "do something with xml"-part is where I'm at at the moment. I get the feeling that this should be really trivial, but I fail to find out how. Is there an "xml.data()" or similar that can be used for this purpose? $.ajax({ url: 'document.xml', type: 'GET', dataType: