xml-parsing

XML Parsing in SQL Server

↘锁芯ラ 提交于 2019-12-08 14:20:13
问题 The requirement is to parse all the 27 values related to MarginRevenue/Cost/Value . As a standard scenario, these elements can come in any order and also can come in any number of time. In short, the XML is completely dynamic. The only point is Under Margins/Margin, there can be any number of MarginRevenue, MarginCost and MarginValue. declare @xml xml = '<Margins> <Margin type="type1" currencyCode="currencyCode1"> <MarginRevenue>1.1</MarginRevenue> <MarginRevenue>1.2</MarginRevenue>

How can I get element from XML file with attribute having specific value

我怕爱的太早我们不能终老 提交于 2019-12-08 13:46:09
问题 XML file: <Node name="node1"> <Node name="node2"> <Node name="node3"> <Node name="node4"> ... </Node> </Node> </Node> </Node> How to select or get "Node" object with "name" attribute having value as "node3" (or any specific value)? Currently I am using xml.etree.ElementTree from xml.etree import ElementTree document = ElementTree.parse( 'filename.xml' ) nodes = document.find( 'Node') for node in nodes: if node.attribute('name') == "node3": print("found") break Is there better way to avoid for

XML: Save several child node's values into php array

点点圈 提交于 2019-12-08 13:37:25
问题 How can I retrieve all <ASIN>..</ASIN> values of this xml and save them to a php variable/array? I tried $result=$xml->xpath('//ASIN'); but this gives me array(0) { } as a browser output. Thank you for your help! I appreciate it very much! This is my xml file: <?xml version="1.0" ?> <ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"> <OperationRequest> <RequestId>...</RequestId> <Arguments> <Argument Name="region" Value="de"></Argument> <Argument Name=

Get XML code count using XMLReader

可紊 提交于 2019-12-08 12:54:32
问题 I am trying to parse product feed that is provided to Google merchant. The thing is I want it to be more interactive so I was using a function that convert XML to array and then show percentage to the user that how much products are updated. I have read that XMLReader is much more efficient then other parsing techniques. How can I make XMLReader more effective. Can I get number of nodes using XMLReader. Or how Can I iterate over XML that it can be more responsive. 回答1: Converting the XML to

dom xml parser java, same tags

烂漫一生 提交于 2019-12-08 12:30:02
问题 i have this xml document which has varying number of same named tags. how can i get the count of the child elements and the value of it. <Question> <QuestionText>ABC?</QuestionText> <Option>A1 - XYZ</Option> <Option>A2 - WXY</Option> <Option>A2 - HJK</Option> <ID>1</ID> </Question> <Question> <QuestionText>ERY?</QuestionText> <QuestionText>NNN?</QuestionText> <QuestionText>KKKK?</QuestionText> <ID>2</ID> </Question> The output should read... ID:2 Has 1 QuestionText and 3 Option QuestionText 1

Scrape with a loop and avoid 404 error

喜夏-厌秋 提交于 2019-12-08 12:11:05
问题 I am trying to scrape wiki for certain astronomy related definitions for my project. The code works pretty well, but I am not able to avoid 404s. I tried tryCatch . I think I am missing something here. I am looking for a way overcome 404s while running a loop. Here is my code: library(rvest) library(httr) library(XML) library(tm) topic<-c("Neutron star", "Black hole", "sagittarius A") for(i in topic){ site<- paste("https://en.wikipedia.org/wiki/", i) site <- read_html(site) stats<- xmlValue

run xpath from xquery against a database?

北城余情 提交于 2019-12-08 11:37:39
问题 How do I run an xpath query from within an xquery script with the basex GUI? successful xpath query of a database: failed xquery attempt: The simplest possible xquery code for this database: thufir@dur:~/basex$ thufir@dur:~/basex$ cat db_list_items.xq let $db := db:open("list") return root()/descendant::li/a/text() thufir@dur:~/basex$ Not quite sure how to return results above. error log from the basex GUI: Error: Stopped at /home/thufir/basex/db_list_items.xq, 4/12: [XPDY0002] root(): no

How do I compare certain values from different XML documents?

坚强是说给别人听的谎言 提交于 2019-12-08 11:35:33
问题 I want to write code in Perl that compares two XML files. A Little bit from the history... With API Documentation (get request) I get data1 form the Web Service1 and data2 from the Service2. They are presented in XML Format, but not the same. I should compare just two elements in these files (deviceName and ipAddress), if they are the same in both files, It should be a message " WebService1 already contains DeviceName "Switch1" ". If not - I would make POST request and add this device in

parsing xml to json in iphone

百般思念 提交于 2019-12-08 11:02:00
问题 Am writing one small application to parse from XML to JSON object for iphone. can anyone tell me the availability of open source library present to do the parsing usnig objective-c. 回答1: There are plenty of open source solutions in objective-c to deal with JSON : JSONKit : https://github.com/johnezang/JSONKit SBJson (aka json-framework) : https://github.com/stig/json-framework YAJL Framework : https://github.com/gabriel/yajl-objc To deal with xml, you can use the default NSXMLParser class or

Map node names using pugixml for different inputs

梦想的初衷 提交于 2019-12-08 10:46:54
问题 Problem My program spits out XML nodes from a file using pugixml . This is the bit of the code which does this: for (auto& ea: mapa) { std::cout << "Removed:" << std::endl; ea.second.print(std::cout); } for (auto& eb: mapb) { std::cout << "Added:" << std::endl; eb.second.print(std::cout); } All nodes spat out should have this format (for example filea.xml): <entry> <id><![CDATA[9]]></id> <description><![CDATA[Dolce 27 Speed]]></description> </entry> However what is spat out depends on how the