xml-parsing

Groovy Node.depthFirst() returning a List of Nodes and Strings?

大城市里の小女人 提交于 2020-01-01 10:48:33
问题 I'm hoping someone will just point out something obvious that I'm missing here. I feel like I've done this a hundred times and for some reason tonight, the behavior coming from this is throwing me for a loop. I'm reading in some XML from a public API. I want to extract all the text from a certain node (everything within 'body'), which also includes a variety of child nodes. Simple example: <xml> <metadata> <article> <body> <sec> <title>A Title</title> <p> This contains <italic>italics</italic

How to get an attribute of an Element that is namespaced

丶灬走出姿态 提交于 2020-01-01 09:42:17
问题 I'm parsing an XML document that I receive from a vendor everyday and it uses namespaces heavily. I've minimized the problem to a minimal subset here: There are some elements I need to parse, all of which are children of an element with a specific attribute in it. I am able to use lxml.etree.Element.findall(TAG, root.nsmap) to find the candidate nodes whose attribute I need to check. I'm then trying to check the attribute of each of these Elements via the name I know it uses : which

How to get an attribute of an Element that is namespaced

不问归期 提交于 2020-01-01 09:42:05
问题 I'm parsing an XML document that I receive from a vendor everyday and it uses namespaces heavily. I've minimized the problem to a minimal subset here: There are some elements I need to parse, all of which are children of an element with a specific attribute in it. I am able to use lxml.etree.Element.findall(TAG, root.nsmap) to find the candidate nodes whose attribute I need to check. I'm then trying to check the attribute of each of these Elements via the name I know it uses : which

Reading XML online and Storing It (Using Java)

我怕爱的太早我们不能终老 提交于 2020-01-01 07:15:19
问题 I found and followed an example from Stackoverflow (http://stackoverflow.com/questions/2310139/how-to-read-xml-response-from-a-url-in-java) of how to read an XML file from a URL (as you can see in my code pasted below). My only trouble is that now that I got the program to read the XML, how do I get it to store it? For example, could I make it save the information to a XML file built into the project (this would be the best solution for me, if it's possible)? Such as, take for example, I have

Loop through xml elements

十年热恋 提交于 2020-01-01 04:27:11
问题 I have the following: $aMyArray = $null [xml]$userfile = Get-Content C:\AppSense\Scripts\AmPolicyConversion\AM_dev.xml $i = 0 FOREACH ($j in $userfile.ChildNodes){ FOREACH($k in $j.DocumentElement) { } $i = $i + 1 } I am trying to figure out how to loop through each element within powershell. Then check for an attribute of SID on the element. If exists get attribute value and put that value into an object and for the same element grab second attribute DISPLAYNAME and place into same object.

Recursively search for parent child combinations and build tree in python and XML

半城伤御伤魂 提交于 2020-01-01 04:23:08
问题 I am trying to traverse this XML data full of parent->child relationships and need a way to build a tree. Any help will be really appreciated. Also, in this case, is it better to have attributes or nodes for the parent-->child relationship? <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <nodes> <node name="Car" child="Engine"/> <node name="Car" child="Wheel"/> <node name="Engine" child="Piston"/> <node name="Engine" child="Carb"/> <node name="Carb" child="Bolt"/> <node name="Spare

Parse XML Libxmljs (Node.js)

不羁岁月 提交于 2020-01-01 02:34:11
问题 I'm attempting to parse an XML string with libxmljs (https://github.com/polotek/libxmljs). I'm having some issues though. I need to apply logic to what I'm parsing and return based upon what's defined and what isn't. Because of this I don't see a SAX-style parser being a valid option. I'm willing to look at other alternatives if I can achieve what I'm looking for. Being able to select elements like DOMParser xmlDoc.getElementsById('firstName')[0].childNodes[0].nodeValue would be awesome...

How to parse xml data with attribute values in android?

浪子不回头ぞ 提交于 2019-12-31 07:00:05
问题 I have a xml data like below <toplevel> <CompleteSuggestion> <suggestion data="madonna"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna like a prayer"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna like a virgin"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna vogue"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna la isla bonita"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna

How to parse xml data with attribute values in android?

北城余情 提交于 2019-12-31 06:59:44
问题 I have a xml data like below <toplevel> <CompleteSuggestion> <suggestion data="madonna"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna like a prayer"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna like a virgin"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna vogue"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna la isla bonita"/> </CompleteSuggestion> <CompleteSuggestion> <suggestion data="madonna

JAXB ignoring xml tag attribute

三世轮回 提交于 2019-12-31 03:00:29
问题 I read xml files with JAXB. I have the following structure <A> <B value="some string" /> </A> I have the following model @XmlRootElement class A{ @XmlElement(name = "B", required = true) @XmlPath("B/@value") String b; } I read the B tags value attribute in my b Instance variable. But in some XML files i have in the B tag following Structure <#B/> While JAXB unmarshall the files i become exception that the format is not correct. javax.xml.stream.XMLStreamException: ParseError at [row,col]:[19