xml-parsing

PHP HTML DOM to parse XML second result

一个人想着一个人 提交于 2019-12-13 01:34:38
问题 I'm using simple PHP HTML DOM to parse XML, it is that there are several tags with the same values​​, how I can display only the second label? 回答1: I'm guessing from your question you're using PHP Simple HTML DOM? http://simplehtmldom.sourceforge.net/ You should be able to get the second label by doing something like: // $xml is your DOM object $tags = $xml->find("label"); echo $tags[1]; If you're not using PHP Simple HTML DOM, let us know which you're using, as it'll be different depending

Removing html tags and content where tag content matches an array of values using Xml.parse()

大憨熊 提交于 2019-12-13 01:28:50
问题 I've extracted some html from GmailApp using .getBody() and would like to return some html which filters a specific tag and contents where the contents matches any value in an array (specifically links with certain text). Looking at this solution I figure the easiest way to do this would be to use Xml.parse() and filter the object but can't get beyond creating the XmlDocument. For example, if: var html = '<div>some text then <div><a href="http://example1.com">foo</a></div> and then <span>some

How to differentiate parent and child tag while dom parsing?

淺唱寂寞╮ 提交于 2019-12-13 01:09:24
问题 I am using dom xml parser in android. In my source xml contains same name for parent and child. How to differentiate parent tag and child tag while parsing xml data? This is my sample xml. <alerts> <alert> <code>QWEOS</code> <alert>this is alert1</alert> <description>this is description</description> </alert> <alert> <code>SDFHP</code> <alert>this is alert2</alert> <description>this is description</description> </alert> </alerts> 回答1: You can create an document doc. NodeList nodes = doc

Xpath query to get the ancester nodes based on element value

一曲冷凌霜 提交于 2019-12-13 00:46:57
问题 I am trying to find all the element names which follow the below two rules. 1. elements should have the <set>erase</set> 2. if two or more elements have the <set>erase</set> in hierarchy (Ex: <b> and <d> both have <set>erase</set> ) then only the parent node name has to be printed(ie <b> in this case). So the required result for below xml needs to be : b , y , p <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <a> <b> <set>erase</set> <d> <set>erase</set> </d> </b> <c> <x> </x> </c> <e

Question Regarding XML Parsing Using SAX in JAVA

我与影子孤独终老i 提交于 2019-12-13 00:14:22
问题 I am trying to parse an XML document in Java (first time attempting to do so), and I have found a number of articles on Google that provide examples but I really don't understand some of the code in them, so I was wondering if someone could explain a few things to me. The primary example I was looking at came from here: http://www.java-tips.org/java-se-tips/org.xml.sax/parsing-xml-with-a-simple-sax-document-handler-2.html. My main questions primarily come from the second half of the code,

Simple Xml Framework loose mapping not working

天大地大妈咪最大 提交于 2019-12-13 00:12:57
问题 I am trying to parse part of an xml document using Simple Xml Framework with the loose mapping flag set but i get an exception. XML: <Body> <TopGoalScorersResponse> <TopGoalScorersResult> <tTopGoalScorer> <sName>Alan Dzagoev</sName> <iGoals>3</iGoals> <sCountry>Y</sCountry> <sFlag>http://footballpool.dataaccess.eu/images/flags/ru.gif</sFlag> <sFlagLarge>http://footballpool.dataaccess.eu/images/flags/ru.png</sFlagLarge> </tTopGoalScorer> </TopGoalScorersResult> </TopGoalScorersResponse> </Body

Properly iterating through XML with namespaces in Groovy

江枫思渺然 提交于 2019-12-13 00:06:11
问题 I have the following xml code: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <cms:RelatedConfigurationItemList xmlns:cms="some namespace"> <ConfigurationItem> <name>data</name> <id>data</id> <type>data</type> <relationship>IS CHILD OF</relationship> <ConfigurationItemList> <ConfigurationItem> <name>data</name> <id>data</id> <type>data</type> <relationship>IS CHILD OF</relationship> <ConfigurationItemList/> </ConfigurationItem> <ConfigurationItem>

Google Sheets ImportXml() imported content can not be parsed

…衆ロ難τιáo~ 提交于 2019-12-12 23:01:04
问题 I'm trying to import data from an XML file online, though it's not working correctly. The formula I'm using is this: =IMPORTXML(https://mobileapp01.graincorp.com.au/prices?site=8440&commodity=1002000, //*[@id="collapsible86"]/div[1]/div[2]/div[1]/span[2]) And it is returning an error saying Imported XML content can not be parsed. Have I done something wrong, or will it simply not work with that XML document? Thanks 回答1: So here is what is happening - despite the fact that that endpoint is

Read/decrypt encrypted XML file and then process internally

喜欢而已 提交于 2019-12-12 19:25:14
问题 I have used this code in the past for writing and reading xml files. This time I want to write some encrypted generated XML and then read it and process it internally. I will post the code and perhaps someone can spot the problem. When I am testing the decrypt I have been able to output a file that has a continuous line of null character codes. The encrypted file seems to contain data and varys in size with different amounts of data. Please help, thanks! Encrypt MemoryStream ms = new

xml.etree.ElementTree.ParseError: not well-formed (invalid token)

感情迁移 提交于 2019-12-12 19:19:54
问题 Using Python 3 Error we get: File "C:/scratch.py", line 27, in run tree = ET.fromstring(responses[0].decode(), ET.XMLParser(encoding='utf-8')) File "C:\Programs\Python\Python36-32\lib\xml\etree\ElementTree.py", line 1314, in XML parser.feed(text) xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 163, column 1106 Our code: tree = ET.fromstring(responses[0].decode(), ET.XMLParser(encoding='utf-8')) for i in tree.iter('item'): try: title = i.find('title').text except