xml-parsing

C# deserialize xml error ReadElementContentAs() methods cannot be called on an element that has child elements

不想你离开。 提交于 2021-01-29 11:25:43
问题 I've looked at several similar SO questions but still can't solve my issue. Using the following code I try to deserialize: private static QCOrderInfo GetOrderFromXml(XDocument xmlDoc){ XmlSerializer serializer = new XmlSerializer(typeof(QCOrderInfo)); var post = (QCOrderInfo)serializer.Deserialize(xmlDoc.Root.CreateReader()); return post ?? new QCOrderInfo(); } The error resulting: System.Xml.XmlException: ReadElementContentAs() methods cannot be called on an element that has child elements.

How to get specific values from a xml file into csv file using python?

不羁的心 提交于 2021-01-29 07:50:32
问题 I am trying to extract object, xmin, ymin, xmax and xmax value of every object tag there is. XML <annotation> <folder>Plates_Number</folder> <filename>1.png</filename> <source> <database>Unknown</database> </source> <size> <width>294</width> <height>60</height> <depth>3</depth> </size> <segmented>0</segmented> <object> <name>2</name> <pose>Unspecified</pose> <truncated>1</truncated> <difficult>0</difficult> <bndbox> <xmin>40</xmin> <ymin>1</ymin> <xmax>69</xmax> <ymax>42</ymax> </bndbox> <

python xml.etree - remove node but keep children (assign children to grandparents)

你说的曾经没有我的故事 提交于 2021-01-29 02:36:47
问题 In Python, how do I remove a node but keep its children using xml.etree API? Yes I know there's an answer using lxml but since xml.etree is part of Python website, I figure it deserves an answer too. Original xml file: <?xml version="1.0"?> <data> <country name="Liechtenstein"> <rank>1</rank> <year>2008</year> <gdppc>141100</gdppc> <neighbor name="Austria" direction="E"/> <neighbor name="Switzerland" direction="W"/> </country> <country name="Singapore"> <rank>4</rank> <year>2011</year> <gdppc

How to properly parse parent/child XML with Python

时光毁灭记忆、已成空白 提交于 2021-01-28 21:34:42
问题 I have a XML parsing issue that I have been working on for the last few days and I just can't figure it out. I've used both the ElementTree built-in to Python as well as the LXML libraries but get the same results. I would like to continue using ElementTree if I can, but if there are limitations to that library then LXML would do. Please see the following XML example. What I am trying to do is find a connection element and see what classes that element contains. I am expecting each connection

Logic for passing variable number of parameters to XSLT

那年仲夏 提交于 2021-01-28 19:53:09
问题 I need to develop an application that will periodically check data from a XML feed , process it and take appropriate actions like notifying the users etc but mostly used to generate and view a report. This xml feed basically checks the uptime, downtime of applications. Here are the steps that i am following: I am downloading a xml file from a remote location to my own server. Check which applications to monitor from a properties file . Transform it to html using a XSLT and mail the html page.

ListView Parsing Persian, Greek, Arabic or UTF-8 xml

痞子三分冷 提交于 2021-01-28 10:09:09
问题 I used a tutorial about listview parsing xm from internet and using LasyAdapter shows the items in listview. When I add persian characters in xml (into one of childnodes) the result is some boxes in listview (after showing the text in listview). The format of xml is UTF-8, too. I used typeface too (but didn't work). Besides when I type Pwesian into the application it shows alright but it can't show Persiann content parsed from xml. Thanks in advance. I updated the post with original XMLparser

How can i parse xml file type of svg? [duplicate]

浪尽此生 提交于 2021-01-28 07:02:20
问题 This question already has answers here : How do I read and parse an XML file in C#? (11 answers) Closed 1 year ago . using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Xml; public class XmlReader : MonoBehaviour { XmlDocument doc = new XmlDocument(); // Use this for initialization void Start () { doc.Load(@"C:\Users\myxml\Documents\mysvg.svg"); XmlNode node = doc.DocumentElement.SelectSingleNode("/g"); foreach (XmlNode nodes in doc.DocumentElement

Tool to convert xsd to c++ code

我的梦境 提交于 2021-01-28 04:21:44
问题 Is there any tool to convert xsd to c++ code. The generated code can be used for serialization and parsing the xml. It should also be run as a independent. I saw some opensource tools like CodeSynthesis but it has covered by GPL license. I am looking for a tool which will generate code that could run independently. 回答1: xsd.exe generates code for C++\CLI too. It is not added in \languages in the documentation. But when executing xsd.exe in VS CommandPrompt, in the \languages section you could

SQL Variable Containing Path in XML Node

风流意气都作罢 提交于 2021-01-28 02:45:49
问题 I need help with passing an XML path through a variable to the nodes() method. I have looked at several different posts and found that a node can be passed by using local-name and sql:variable . The example below works as expected: DECLARE @XML_Path VARCHAR(MAX) , @XML_In XML SET @XML_Path = 'GetData' SET @XML_In = ' <GetData> <test>234</test> </GetData> ' --THIS WORKS SELECT Item_Idx = Nodes.value('(test)[1]' ,'INT') FROM @XML_In.nodes('/*[local-name()=sql:variable("@XML_Path")]') Results

SQL Variable Containing Path in XML Node

杀马特。学长 韩版系。学妹 提交于 2021-01-27 21:50:23
问题 I need help with passing an XML path through a variable to the nodes() method. I have looked at several different posts and found that a node can be passed by using local-name and sql:variable . The example below works as expected: DECLARE @XML_Path VARCHAR(MAX) , @XML_In XML SET @XML_Path = 'GetData' SET @XML_In = ' <GetData> <test>234</test> </GetData> ' --THIS WORKS SELECT Item_Idx = Nodes.value('(test)[1]' ,'INT') FROM @XML_In.nodes('/*[local-name()=sql:variable("@XML_Path")]') Results