xmldocument

Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2

好久不见. 提交于 2019-11-30 16:49:58
问题 While loading XML file in a C# application, I am getting Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2. The XML tag begins like this. <version="1.0" encoding="us-ascii" standalone="yes" /> <1212041205115912> I am not supposed to change this tag at any cost. How can I resolve this? 回答1: IF you absolutely cant change it , eg. for some reason the format is already out in the wild and used by other systems/customers/whatever. Since it is an invalid xml

XmlDocument.Load fails, LoadXml works:

江枫思渺然 提交于 2019-11-30 13:26:31
In answering this question , I came across a situation that I don't understand. The OP was trying to load XML from the following location: http://www.google.com/ig/api?weather=12414&hl=it The obvious solution is: string m_strFilePath = "http://www.google.com/ig/api?weather=12414&hl=it"; XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(m_strFilePath); //Load NOT LoadXml However this fails with XmlException : Invalid character in the given encoding. Line 1, position 499. It seems to be choking on the à of Umidità . OTOH, the following works fine: var m_strFilePath = "http://www

Which namespace is necessary to use SelectSingleNode() method (using default namespace and can't use the method)

此生再无相见时 提交于 2019-11-30 09:49:08
问题 Hi I have xml file (which is actually msbuild file) that uses different namespace <?xml version="1.0" ?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition="'$(key)'=='1111'"> <Key>Value</Key> </PropertyGroup> </Project> But the problem is I can't use SelectSingleNode with that file because of xmlns="http://schemas.microsoft.com/developer/msbuild/2003" I believe it's since default namespace (necessary for the method) is gone

C# : Modify a xml node

社会主义新天地 提交于 2019-11-30 08:05:45
问题 i have that xml file : <?xml version="1.0" encoding="utf-8"?> <reminders> <reminder> <Title>Alarm1</Title> <Description>Desc1</Description> <Time>03/07/2012 10:11AM</Time> <snooze>1</snooze> <repeat>None</repeat> </reminder> </reminders> And i want to modify the innertext from Alarm1 to another value so i wrote that code which actually duplicate the entire node . XmlDocument xml = new XmlDocument(); xml.Load("0.xml"); XmlNodeList elements = xml.SelectNodes("//reminders"); foreach (XmlNode

Parse malformed XML

半腔热情 提交于 2019-11-30 04:59:59
问题 I'm trying to load a piece of (possibly) malformed HTML into an XMLDocument object, but it fails with XMLExceptions... since there are extra opening/closing tags, and malformed XML tags such as <img > instead of <img /> How do I get the XML to parse with all the errors in the data? Is there any XML validator that I can apply before parsing, to correct these errors? Or would handling the exception parse whatever can be parsed? 回答1: The HTML Agility Pack will parse html, rather than xhtml, and

Can't get XmlDocument.SelectNodes to retrieve any of my nodes?

限于喜欢 提交于 2019-11-30 02:01:02
I'm trying to parse an XML document. The document in question is an AppxManifest file. An example document looks like this: <?xml version="1.0" encoding="utf-8"?> <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:build="http://schemas.microsoft.com/developer/appx/2012/build" IgnorableNamespaces="build"> <Identity Name="uytury" Publisher="hygj" Version="1.0.0.12" ProcessorArchitecture="neutral" /> <Properties> <DisplayName>jhjj</DisplayName> <PublisherDisplayName>bhhjb</PublisherDisplayName> <Logo>Assets\StoreLogo.png</Logo> </Properties> <Prerequisites> <OSMinVersion>6.2.1

XmlDocument.Load fails, LoadXml works:

半腔热情 提交于 2019-11-29 19:15:13
问题 In answering this question, I came across a situation that I don't understand. The OP was trying to load XML from the following location: http://www.google.com/ig/api?weather=12414&hl=it The obvious solution is: string m_strFilePath = "http://www.google.com/ig/api?weather=12414&hl=it"; XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(m_strFilePath); //Load NOT LoadXml However this fails with XmlException : Invalid character in the given encoding. Line 1, position 499. It

Which namespace is necessary to use SelectSingleNode() method (using default namespace and can't use the method)

穿精又带淫゛_ 提交于 2019-11-29 17:00:42
Hi I have xml file (which is actually msbuild file) that uses different namespace <?xml version="1.0" ?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition="'$(key)'=='1111'"> <Key>Value</Key> </PropertyGroup> </Project> But the problem is I can't use SelectSingleNode with that file because of xmlns="http://schemas.microsoft.com/developer/msbuild/2003" I believe it's since default namespace (necessary for the method) is gone because of xmlns above. Then I think I just need to add necessary one for that.. But my tries weren't

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

ⅰ亾dé卋堺 提交于 2019-11-29 16:13:35
[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 that there is no root element. [Current workaround] Of course I can read the file as a stream, append <

String greater, less, and equal comparison in XmlDocument

耗尽温柔 提交于 2019-11-29 15:42:26
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']"); XmlNodeList test3 = x2PathDoc.SelectNodes("//config /pendingversion[@test > 'b']"); XmlNodeList