jdom

Error change values in node of a xml

时光毁灭记忆、已成空白 提交于 2020-01-04 14:00:59
问题 I need to change several values of an xml, but when I run the line .setText, it shows the java.lang.NullPointerException error and I do not understand why. <?xml version="1.0" encoding="UTF-8"?> <prueba> <reg id="576340"> <dato cant="680" id="1" val="-1" num="" desc="" /> <dato cant="684" id="5" val="-1" num="" desc="" /> <dato cant="1621" id="1" val="-1" num="" desc="Hi" /> <dato cant="1625" id="5" val="-1" num="" desc="Hola" /> </reg> </prueba> This is the code: public static void main

jdom performance

荒凉一梦 提交于 2020-01-04 10:43:50
问题 I am currently using native Java XML processing library (Xerces). I can't use any sax parser because I need random access to xml nodes. I am finding that CPU usage goes 100% when I am parsing XML files. There are large number of small size (1-10kb) that I am processing like this- while(hasFile){ processXMlfile(hasFile.next); } In processXMlfile() I am building parsing and processing file. If I move to JDOM library, will I gain any performance benefit? 回答1: The bottleneck is probably XML

jdom performance

时光毁灭记忆、已成空白 提交于 2020-01-04 10:43:33
问题 I am currently using native Java XML processing library (Xerces). I can't use any sax parser because I need random access to xml nodes. I am finding that CPU usage goes 100% when I am parsing XML files. There are large number of small size (1-10kb) that I am processing like this- while(hasFile){ processXMlfile(hasFile.next); } In processXMlfile() I am building parsing and processing file. If I move to JDOM library, will I gain any performance benefit? 回答1: The bottleneck is probably XML

jdom performance

ぃ、小莉子 提交于 2020-01-04 10:43:05
问题 I am currently using native Java XML processing library (Xerces). I can't use any sax parser because I need random access to xml nodes. I am finding that CPU usage goes 100% when I am parsing XML files. There are large number of small size (1-10kb) that I am processing like this- while(hasFile){ processXMlfile(hasFile.next); } In processXMlfile() I am building parsing and processing file. If I move to JDOM library, will I gain any performance benefit? 回答1: The bottleneck is probably XML

How to remove a child from from a node using jdom in java?

ぐ巨炮叔叔 提交于 2019-12-31 04:26:09
问题 I have a xml structure as follows: <rurl modify="0" children="yes" index="8" name="R-URL"> <status>enabled</status> <rurl-link priority="3">http</rurl-link> <rurl-link priority="5">http://localhost:80</rurl-link> <rurl-link priority="4">abc</rurl-link> <rurl-link priority="3">b</rurl-link> <rurl-link priority="2">a</rurl-link> <rurl-link priority="1">newlinkkkkkkk</rurl-link> </rurl> Now, I want to remove a child node, where text is equal to http. currently I am using this code: while

Remove XML attribute using JDOM API?

自古美人都是妖i 提交于 2019-12-25 00:40:19
问题 I have a JDOM element like the following Example:XML(JDOM Element) <Details> <Uniqueno>11111</Uniqueno> <ROWSET name="Persons"> <ROW num="1"> <Name>60821894</Name> <Age>938338789</Age> </ROW> <ROW num="2"> <Name>60821894</Name> <Age>938338789</Age> </ROW> </ROWSET> </Details> I want to convert like: <Details> <Uniqueno>11111</Uniqueno> <ROW num="1"> <Name>60821894</Name> <Age>938338789</Age> </ROW> <ROW num="2"> <Name>60821894</Name> <Age>938338789</Age> </ROW> </Details> note:ROWSET element

jdom removes duplicate namespace declaration (xmloutputter)

孤街醉人 提交于 2019-12-23 05:51:53
问题 jdom seems to remove duplicate namespace declarations. This is a problem when a XML document is embedded into another XML structure, such as for example in the OAI-PHM (open archive initiative). This can be a problem when the surrounding xml is only a container and the embedded document gets extracted later. Here is some code. The embedded xml is contained in the string with the same name. It declares the xsi namespace. We construct a jdom container, also declaring the xsi namespace. We parse

how to insert value into xml?

谁都会走 提交于 2019-12-23 03:17:06
问题 I am really new to XML and JDOM so I have a noob question, sorry for that. I have a XML file and I want to insert value into it. My XML file is like that; <?xml version="1.0"?> <message> <header> <messageType> </messageType> <sendFrom> </sendFrom> <HostName> </HostName> <sendTo> </sendTo> <receiverName> </receiverName> <date> </date> </header> <body> </body> </message> So what I want is for example is to add value between <sendTo> </sendTo> and also I want to add <A> data </A> between <body>

check the compatibility of an XML document against a DTD using JDOM?

独自空忆成欢 提交于 2019-12-20 07:26:59
问题 I am working with Java and I want to check if an XML file is valid against a DTD. Assuming that we do have a DTD file, I want to check if certain XML file is valid against the same definitions proposed in the DTD file. Is there any way to do it using JDOM? 回答1: Yes, you can, in JDOM. It's easiest in JDOM 2.x (as opposed to 1.x). See the SAXBuilder constructor that takes an XMLReaderJDOMFactory. An example usage is: SAXBuilder sb = new SAXBuilder(XMLReaders.DTDVALIDATING); Document doc = sb

Java out of memory Exception

核能气质少年 提交于 2019-12-18 16:55:13
问题 I am running a Java Web Application in Tomcat. The application uses Quartz framework to schedule the cron job at regular intervals. This cron job involves parsing a 4+ MB xml file, which I am doing using JDOM API. The xml file contains around 3600 nodes to be parsed and consequently data to be updated in DB which I am doing it sequentially. After parsing almost half of the file, my application throws a Out of Memory Exception. The stack trace of the same is : Exception in thread