xml-parsing

How to get the attribute value of xml using LINQ to XML?

别等时光非礼了梦想. 提交于 2019-12-11 16:53:42
问题 I have the following xml schema. <Rooms> <Room RoomNumber="room1" EMAIL="ssds@dsfd.com" dsfdd=""/> <Room RoomNumber="room2" EMAIL="ssds@sdd.com" dsfdd=""/> </Rooms> I have to return Email address based on the input(input to program is room number). How i can achieve this using LINQ to XML? 回答1: var doc = XDocument.Load(myXmlFilePath); // or doc = XDocument.Parse(myXmlString); string roomNumber = "room1"; var emailQuery = from room in doc.Root.Elements("Room") where (string)room.Attribute(

How to parse this format of xml data?

て烟熏妆下的殇ゞ 提交于 2019-12-11 16:37:30
问题 i tried to parse data of this format of xml: <?xml version="1.0" encoding="UTF-8"?> <root> <list info="INFY, Jan 20 call, 40 cents or Lower" profit="60%" loss="gdh"/> <list info="HPCL, Feb 20 PUT, 20 cents or Lower" profit="80%" loss="fgh"/> <list info="AAPL, May 290 call, 90 cents or Lower" profit="ss" loss="20%"/> <list info="DIA, April 105 call, 32 cents or Lower" profit="ghh" loss="20%"/> <list info="GOOG, Aug 350 call, 47 cents or Lower" profit="100%" loss="sdgd"/> </root> using this

Assert condition to optimize the query in XSD

ぃ、小莉子 提交于 2019-12-11 16:13:44
问题 I have an XSD where i have to use assert condition. I would want to print all columns for condition when indicator='A' and few columns another condition is indicator='D'. I have the below logic but i have around 100 columns so can anyone help me with optimizing the query? <xs:assert test="if (indicator eq 'A') then test1 and test2 and test3 and test4 and test5 and test6 and test7 else if (indicator eq 'B') then test1 and test3 else false()"/> The input XML is in this format: `<?xml version="1

Regex to get value within tag

本秂侑毒 提交于 2019-12-11 15:56:45
问题 I have a sample set of XML returned back: <rsp stat="ok"> <site> <id>1234</id> <name>testAddress</name> <hostname>anotherName</hostname> ... </site> <site> <id>56789</id> <name>ba</name> <hostname>alphatest</hostname> ... </site> </rsp> I want to extract everything within <name></name> but not the tags themselves, and to have that only for the first instance (or based on some other test select which item). Is this possible with regex? 回答1: The best tool for this kind of task is XPath. NSURL

XMLTV spanish characters not appearing correctly

旧城冷巷雨未停 提交于 2019-12-11 15:54:01
问题 I have been working with XMLTV and I have found that Spanish characters are not appearing in the EPG correctly, I believe this will be an issue with the xml encoding but I have tested this with both: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="UTF-8" ?> And I am still having issues with Spanish characters, any suggestions? Update: I am reading in an xml file and converting it to XMLTV, everything works correctly as expected apart from the spanish characters. void

Parsing French text with simple-Framework not working

六月ゝ 毕业季﹏ 提交于 2019-12-11 15:36:33
问题 I'm using simpleFramework for parsing an xml file in my android app. My problem is in parsing french text like lets say this tag <TagName>écrite</TagName> The result I will receive when parsing is something like this "écrite" This is encoding (french) problem in the simpleFramework xml. How can avoid that and have my text "écrite" the xml header has utf8 : <?xml version="1.0" encoding="UTF-8"?> 回答1: I have hit this issue before whilst using a SAX parser. When reading the file with a Java

Populating list values using xstream

喜欢而已 提交于 2019-12-11 15:23:51
问题 I am working with Xstream to read some xml in the following format <Objects> <Object Type="System.Management.Automation.Internal.Host.InternalHost"> <Property Name="Name" Type="System.String">ConsoleHost</Property> <Property Name="Version" Type="System.Version">2.0</Property> <Property Name="InstanceId" Type="System.Guid">7e2156</Property> </Object> </Objects> Basically under Objects tag there can be n number of Object Type and each Object Type can have n number of Property tags. So I have

Cherrypy and Parsing XML Data from multiple files

那年仲夏 提交于 2019-12-11 15:23:35
问题 So this is sort of a piggy-back post of another question I had. I've successfully pulled data from multiple xml files and am able to get the data to display within the terminal using the print function, but when I try to use the return function to show the data in the browser, I only get the data from the first file. Any ideas on why I only get data from the first file rather than all of them? Thanks! from xml.dom.minidom import parse, parseString import os, glob, re import cherrypy class

Combining XML files in php

[亡魂溺海] 提交于 2019-12-11 15:23:03
问题 I am getting external xml files (through file exchange) and I am able to read and store in the database (php/mysql). The xml files come zipped under different names and sometimes several files come together zipped in a folder When the folder has only 1 xml file,I am able to successfully unzip and read the content using $path = '/xmlFile'; //the xmlFile names are in this format : xmFile-00001235.xml, //xmlFile-000012390.xml, etc. only first portions are consistent foreach (glob($path.'/xmlFile

Android RSS Reader cuts off after first pragraph

和自甴很熟 提交于 2019-12-11 15:07:27
问题 I am creating an app for my school newspaper and am running into a problem when trying to display the full article. Currently I have a list of articles appear that are pulled from an RSS feed, and when one is clicked on it brings up the content of the article. However only the first paragraph displays in the TextView, no matter how long it is. This leads me too believe that it has something to do with the <p></p> HTML tags. I am not that familiar with RSS feeds or parsing XML(this being my