|
From: <jz...@xi...> - 2014-05-31 00:38:17
|
will look into this and get back
----- Original Message -----
From: W K
To:"vtd...@li..." , "jz...@xi..."
Cc:
Sent:Tue, 27 May 2014 17:21:52 -0400
Subject:XMLModifier remove all elements of type 'x'
I have the following xml snippet:
5
1
2
5
1
2
3
1
4
5
I need to remove all elements: 1
I have the following code snippet to remove all of the elements:
XM.bind(VN); [1]
AutoPilot ap = new AutoPilot( VN );
// find all note-id elements with a value of
'1'
String xpath = "//note-id[text()='1']";
ap.selectXPath( [2] xpath );
int i = -1;
while ( ( i = ap.evalXPath() [3] ) != -1 ) {
log.debug( [4] "element/value: " +
VN.toNormalizedString( [5] VN.getCurrentIndex() [6] ) + "/" +
VN.toNormalizedString( [7] VN.getText() [8] ));
XM.remove(); [9]
}// while
If I just print out the xpath results, the element names and values
are correct. However, when trying to remove each value, I get the
following error:
java.lang.ArrayIndexOutOfBoundsException: [10] -1
at
com.ximpleware.FastLongBuffer.longAt(FastLongBuffer.java:309) [11]
at com.ximpleware.VTDNav.getTokenDepth(VTDNav.java:1327) [12]
at com.ximpleware.VTDNav.getElementFragment(VTDNav.java:1079)
[13]
at com.ximpleware.XMLModifier.remove(XMLModifier.java:210)
[14]
at
com.razorphish.android.util.XmlUtil.deleteNoteIds(BibleNotesXmlUtil.java:633)
[15]
at
com.razorphish.android.test.XmlUtilTest.deleteNoteById(BibleNotesXmlUtilTest.java:146)
[16]
at
com.razorphish.android.test.XmlUtilTest.test(BibleNotesXmlUtilTest.java:49)
[17]
What is the best practice for removing these elements in bulk?
Thanks for any help you can provide.
Links:
------
[1] http://sitemail.hostway.com/http:
[2] http://sitemail.hostway.com/http:
[3] http://sitemail.hostway.com/http:
[4] http://sitemail.hostway.com/http:
[5] http://sitemail.hostway.com/http:
[6] http://sitemail.hostway.com/http:
[7] http://sitemail.hostway.com/http:
[8] http://sitemail.hostway.com/http:
[9] http://sitemail.hostway.com/http:
[10] http://java.lang.ArrayIndexOutOfBoundsException
[11] http://sitemail.hostway.com/http:
[12] http://sitemail.hostway.com/http:
[13] http://sitemail.hostway.com/http:
[14] http://sitemail.hostway.com/http:
[15] http://sitemail.hostway.com/http:
[16] http://sitemail.hostway.com/http:
[17] http://sitemail.hostway.com/http:
|