xml-parsing

Proper way to parse XML using pugixml

自闭症网瘾萝莉.ら 提交于 2021-02-19 05:35:08
问题 I have an XML file that I need to parse and I'm struggling with using PugiXML to parse out all elements and attributes. I have the following XML file: <?xml version = '1.0' encoding = 'UTF-8'?> <PanelList DefaultTheme="konami" > <Panel xpos="0" ypos="0" width="800" height="600" imagepath="./%THEME%/background_uga_large.png" name="AttractMode0" > <GameViewport xpos="0" ypos="0" width="630" height="526" name="gameviewport"/> <ValueLabel xpos="120" ypos="550" width="448" height="30" fontsize="18

Python: xPath not available in ElementTree

孤人 提交于 2021-02-19 04:45:35
问题 I am trying to parse iTunes Playlist by using iterparse() of ElementTree but getting following error: AttributeError: 'Element' object has no attribute 'xpath' Code is given below: import xml.etree.ElementTree as ET context = ET.iterparse(file,events=("start", "end")) # turn it into an iterator context = iter(context) # get the root element event, root = context.next() for event, elem in context: z = elem.xpath(".//key") elem.clear() root.clear() print z What I am doing wrong? File is too big

XPath simple conditional statement? If node X exists, do Y?

左心房为你撑大大i 提交于 2021-02-19 01:34:24
问题 I am using google docs for web scraping. More specifically, I am using the Google Sheets built in IMPORTXML function in which I use XPath to select nodes to scrape data from. What I am trying to do is basically check if a particular node exists, if YES, select some other random node. /*IF THIS NODE EXISTS*/ if(exists(//table/tr/td[2]/a/img[@class='special'])){ /*SELECT THIS NODE*/ //table/tr/td[2]/a } 回答1: You don't have logic quite like that in XPath, but you might be able to do something

Should I be using XSD 1.1 to build an open standard?

独自空忆成欢 提交于 2021-02-19 00:55:09
问题 We have been asked to put together a set of schemas for an open XML standard. XSD 1.0 would cope with most of the rules, but it would be a bit messy in places (especially to allow for extensibility) it would also rely on implementers reading free text descriptions of some rules in the form of annotations. Pretty much all of the rules could be implemented using XSD 1.1, however we are not sure if this would limit implementers unduly. So my question, is XSD 1.1 mature enough to be used in the

Java.lang.NumberFormatException error: empty string- Exchange Rate application

∥☆過路亽.° 提交于 2021-02-17 06:55:12
问题 I'm writing a program which gets daily exchange rates from http://www.tcmb.gov.tr/kurlar/today.xml and saves them to the List. Here is my code: public class ParseTheXml { private List<CurrencyPojo> currencyList; public void setCurrencyList(List<CurrencyPojo> currencyList) { this.currencyList = currencyList; } public List<CurrencyPojo> getCurrencyList() throws ParserConfigurationException { currencyList = new ArrayList<CurrencyPojo>(); try { DocumentBuilder builder = DocumentBuilderFactory

How to do a partial conditioning on a tag for find_all() in bs4?

淺唱寂寞╮ 提交于 2021-02-11 12:35:12
问题 I have an xml which has multiple tags which look like this: <textblock height="55" hpos="143" id="Page1_Block5" lang="en-US" stylerefs="StyleId-E6BF91A3-3D6A-442F-9A46-22A0459A02E9- font1" vpos="226" width="393"> I want to get all the <textblock> tags clustered by a Page ( id property in the textblock tag). However, my id is written in the following way: id="Page1_Block5" . However, I want to condition only on the Page number, and not the block number. (I want all blocks of a specific page).

Meteorological Data from XML to Dataframe in R

时光怂恿深爱的人放手 提交于 2021-02-11 10:36:47
问题 I´m trying to analize meteorological data, importing directly to R from it´s native structure in XML. But it seems to be a very complicated XML format not corresponding to the commonly used standard of "one observation per row". The provider of the data has grouped the variables by every ten minutes intervals registered. Here is a piece of the XML code: <?xml version= "1.0" encoding="ISO-8859-1" ?> <mes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C069

Parsing an XML file in python for emailing purposes

◇◆丶佛笑我妖孽 提交于 2021-02-11 10:25:47
问题 I am writing code in python that can not only read a xml but also send the results of that parsing as an email. Now I am having trouble just trying to read the file I have in xml. I made a simple python script that I thought would at least read the file which I can then try to email within python but I am getting a Syntax Error in line 4. root.tag 'log' Anyways here is the code I written so far: import xml.etree.cElementTree as etree tree = etree.parse('C:/opidea.xml') response = tree.getroot

XML. SAX . Attributes with default value

£可爱£侵袭症+ 提交于 2021-02-11 05:52:34
问题 I process XML files using SAX : XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); reader.setFeature("http://xml.org/sax/features/validation", Boolean.TRUE); reader.setFeature("http://apache.org/xml/features/validation/schema", Boolean.TRUE); I load a grammar (XSD) and set it to the reader. reader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", grammarPool); The grammar contains defaultValue for some optional attribute of some

Writing a Python tool to convert XML to Python?

大城市里の小女人 提交于 2021-02-10 16:24:34
问题 I've been asked to look in to the possibility of converting XML to Python, so that the XML can be phased out of the current process & they'd be replaced with new python scripts. Currently the XML files are used by python & ASP and look essentially like this; <?xml version="1.0" encoding="UTF-8"?> <script> <stage id="stage1" nextStage="stage2"> <initialise> <variable id="year" value="2012" type="Integer"/> <executeMethod class="engineclass_date" method="getTodayAsString"> <arguments> <variable