vtd-xml

VTD-XML Exception: Name space qualification Exception: prefixed attribute not qualified

匆匆过客 提交于 2020-06-28 10:19:51
问题 I receive an XML via a web service and I am using legacy code (which uses dom4j) to perform some xml transformation. Loading/parsing the original XML into VTD-XML (VTDGen) works fine, no exceptions thrown. However, after loading the xml into dom4j, I noticed some of the element namespace declarations and attributes are re-arranged. Apparently, this re-arrangement causes VTD-XML to throw the following exception: Exception: Name space qualification Exception: prefixed attribute not qualified

使用XPath获取属性

旧街凉风 提交于 2020-03-13 19:43:28
给定这样的XML结构: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> 我如何获取第一个元素 lang 的值(其中 lang 是书名中的 eng )? #1楼 谢谢! 这解决了我在Div中使用data属性遇到的类似问题。 <div id="prop_sample" data-want="data I want">data I do not want</div> 使用此xpath: //*[@id="prop_sample"]/@data-want 希望这对别人有帮助! #2楼 您可以尝试以下xPath模式, XPathExpression expr = xPath.compile("/bookstore/book/title[@lang='eng']") #3楼 您也可以通过 string(//bookstore/book[1]/title/@lang) string(//bookstore

Remove the remaining new line after using VTD-XML to remove an element

纵然是瞬间 提交于 2020-02-25 04:42:07
问题 I'm trying to remove a set of child elements from a parent element using VTD-XML. Unfortunately after removing an element, it leaves behind the new line that the removed element previously occupied. This behaviour is also observed by a reader of an article on VTD-XML by the VTD-XML author here. I'm trying to work out how to remove this new line. I managed to achieve a modicum of success by manipulating the length value stored in the underlying 64-bit VTD token to cover the new line character

How to get Attribute values from Select path or select Attribute ximpleware

半世苍凉 提交于 2020-01-23 17:56:07
问题 <ConfiguredItems> <OtapiConfiguredItem> <Id>3117283038955</Id> <Quantity>1693</Quantity> <Configurators> <ValuedConfigurator Pid="1627207" Vid="3232480" /> <ValuedConfigurator Pid="20509" Vid="28314" /> </Configurators> </OtapiConfiguredItem> <OtapiConfiguredItem> <Id>3117283038956</Id> <Quantity>1798</Quantity> <Configurators> <ValuedConfigurator Pid="1627207" Vid="3232480" /> <ValuedConfigurator Pid="20509" Vid="6145171" /> </Configurators> </OtapiConfiguredItem> <OtapiConfiguredItem> <Id

How can you save the constant update and the finally save the output as a file with XMLModifier

∥☆過路亽.° 提交于 2020-01-14 03:36:09
问题 I have different methods trying to update/remove elements/tokens based on the path. Right now, each method, after it done edited, it straight away save as a file, VTDGen vg = new VTDGen(); vg.parseFile("input.xml", false); vn.getNav(); AutoPilot ap = new AutoPilot(vn); XMLModifier xm; public void updateToken(String path) { xm = new XMLModifier(vn); ap.selectXPath(path); ...... xm.updateToken(i,"hello"); ...... xm.output("output.xml"); } And if I continue to call this method again, it does

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

雨燕双飞 提交于 2020-01-12 07:55:09
问题 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

Modify XML and remove old nodes with VTD-XML

回眸只為那壹抹淺笑 提交于 2019-12-23 01:03:18
问题 I have a structure like this: <Hotels> <Hotel> <Name>Hotel 1</Name> <Phone1>11111-1</Phone1> <Phone2>11111-2</Phone2> </Hotel> <Hotel> <Name>Hotel 2</Name> <Phone1>22222-1</Phone1> <Phone2>22222-2</Phone2> </Hotel> ... </Hotels> And I want to modify every phone number to have a structure like this: <Phone> <Number>11111-1</Number> </Phone> I'm extracting the numbers and building the new nodes. But I don't know at what point I should remove the old Phone1 and Phone2 nodes. My code: VTDGen vg =

Parse xml file using vtd-xml

a 夏天 提交于 2019-12-19 04:18:11
问题 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

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

北战南征 提交于 2019-12-10 10:35:05
问题 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>

Modify XML and remove old nodes with VTD-XML

不羁的心 提交于 2019-12-08 19:35:36
I have a structure like this: <Hotels> <Hotel> <Name>Hotel 1</Name> <Phone1>11111-1</Phone1> <Phone2>11111-2</Phone2> </Hotel> <Hotel> <Name>Hotel 2</Name> <Phone1>22222-1</Phone1> <Phone2>22222-2</Phone2> </Hotel> ... </Hotels> And I want to modify every phone number to have a structure like this: <Phone> <Number>11111-1</Number> </Phone> I'm extracting the numbers and building the new nodes. But I don't know at what point I should remove the old Phone1 and Phone2 nodes. My code: VTDGen vg = new VTDGen(); vg.setDoc(bytes); vg.parse(true); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot