vtd-xml

How to get Inner array child element in XML using ximpleware

自闭症网瘾萝莉.ら 提交于 2019-12-06 15:39:53
AutoPilot searchProperties = new AutoPilot(); searchProperties.selectXPath("/BatchItemSearchResultAnswer/Result/SearchProperties/Content/Item"); searchProperties.bind(nav); searchPro searchOption = new searchPro(); while (searchProperties.evalXPath() != -1) { //reuser name.resetXPath(); name.selectXPath("Name"); searchOption.id = Id.evalXPathToString(); searchOption.name = name.evalXPathToString(); Log.e("SearchId", Id.evalXPathToString()); Log.e("SearchName", name.evalXPathToString()); Image.resetXPath(); Image.selectXPath("/BatchItemSearchResultAnswer/Result/SearchProperties/Content/Item

VTD-XML seems to be spoiling escaped string in XML document

∥☆過路亽.° 提交于 2019-12-06 12:35:39
I am working on an XML data set (the DrugBank database available here ) where some fields contain escaped XML characters like "&", etc. To make the problem more concrete, here is an example scenario: <drugs> <drug> <drugbank-id>DB00001</drugbank-id> <general-references> # Askari AT, Lincoff AM: Antithrombotic Drug Therapy in Cardiovascular Disease. 2009 Oct; pp. 440–. ISBN 9781603272346. "Google books":http://books.google.com/books?id=iadLoXoQkWEC&pg=PA440. </general-references> . </drug> <drug> ... </drug> ... </drugs> Since the entire document is huge, I am parsing it as follows: VTDGen gen

Map supplementary Unicode characters to BMP (if possible)

白昼怎懂夜的黑 提交于 2019-12-06 07:22:51
I ran into the issue that my XML parser (VTD-XML) doesn't seem to be able to handle Unicode Supplementary characters (please correct if I'm already wrong here). It seems, the parser only uses the lower 16 bit of such characters. I cannot switch to another parser within the project I'm occupied with. I am parsing Medline abstracts ( https://www.ncbi.nlm.nih.gov/pubmed ) and it seems there have been added documents that contain supplementary characters over the last year (e.g. https://www.ncbi.nlm.nih.gov/pubmed/?term=26855708 , ends of results section). As a quick and dirty fix I would just

VTD-XML in Java - Find index after XMLModifier.insertAfterElement

北慕城南 提交于 2019-12-04 23:47:29
问题 I've started using VTD (I guess VTD-XML) in Java, and for XPath reads it's excellent. Where i'm hitting an issue now is with inserting data. Lets say I am doing the following: VTDNav nav = preExistingGen.getNav(); AutoPilot pilot = new AutoPilot(nav); pilot.selectXPath("/Something/SomethingElse"); if (pilot.evalXPath() != -1) { XMLModifier modifier = new XMLModifier(nav); modifier.insertAfterElement("<some>content</some>"); } What I had assumed was this was a real-time update, which would be

VTD-XML in Java - Find index after XMLModifier.insertAfterElement

主宰稳场 提交于 2019-12-03 16:10:02
I've started using VTD (I guess VTD-XML) in Java, and for XPath reads it's excellent. Where i'm hitting an issue now is with inserting data. Lets say I am doing the following: VTDNav nav = preExistingGen.getNav(); AutoPilot pilot = new AutoPilot(nav); pilot.selectXPath("/Something/SomethingElse"); if (pilot.evalXPath() != -1) { XMLModifier modifier = new XMLModifier(nav); modifier.insertAfterElement("<some>content</some>"); } What I had assumed was this was a real-time update, which would be reflected in the VTDNav. It looks like my understanding is incorrect, since simply inserting the

Using xpath and vtd-xml to get sub nodes and text of an element as a string

Deadly 提交于 2019-12-03 15:58:48
This is a portion of my XML: <MAIN> <L> <D>string1 string2 <b>string3</b> string4</D> </L> <L> <D>string5 string6 <b>string7</b> string8 <i>string9</i></D> </L> </MAIN> I want to get the content of all the <D> tags as string. So, the example above should return: 1st iteration: 'string1 string2 <b>string3</b> string4' 2nd iteration: 'string5 string6 <b>string7</b> string8 <i>string9</i>' etc... In vtd-xml I used an AutoPilot with XPath "//L/D" and "//L/D/text()" but that did not work. Any advice or alternative approach will be appreciated. Regards Below is the code that does what you are

How to remove a specific node using VTD-XML parser

主宰稳场 提交于 2019-12-01 12:48:52
问题 With the VTD-XML parser how do I do below. <root> <A> <B> <c>1<c/> <d>2<d/> <e>3<e/> </B> <B> <c>1<c/> <d>2<d/> <e>3<e/> </B> </A> </root> In the above xml how do I remove only nodes has tag name ? So my final out put should be <root> <A> </A> </root> 回答1: This is the code that removes all child nodes of A, the key is VTDNav's getContentFragment(). import com.ximpleware.*; public class removeNode { public static void main(String s[]) throws Exception{ VTDGen vg = new VTDGen(); boolean b = vg

Android - XPath evaluate very slow

≯℡__Kan透↙ 提交于 2019-12-01 10:47:24
I'm using XPath to query my XML-file which has at the moment about 100KB . I'm iterating of an array and query for every value in the list. Unfortunately a single query takes about 3-4 seconds under the debugger and slightly less with debugger disabled. Any ideas why this is so slow? I use a Galaxy S2 for testing. Here's my code: XPath xpath = XPathFactory.newInstance().newXPath(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document document = builder.parse

Parse xml file using vtd-xml

江枫思渺然 提交于 2019-12-01 01:22:57
How can i parse a xml file like the following using vtd-xml in java or C ? <?xml version="1.0" encoding="utf-8"?> <StockReport> <Article Code="027783012" Height="35" Width="36" Length="136" TotalPacks="4" AvailablePacks="4" StockReturnPacks="4" BlockedPacks="0" NextExpiryDate="2015-01-17"> <Machine Number="1" TotalPacks="4" AvailablePacks="4" StockReturnPacks="4" BlockedPacks="0" NextExpiryDate="2015-01-17" /> </Article> <Article Code="025349109" Height="36" Width="37" Length="129" TotalPacks="6" AvailablePacks="6" StockReturnPacks="6" BlockedPacks="0" NextExpiryDate="2015-01-17"> <Machine