← Prev in month ← Prev in thread

[Java] Create a new StAX parser...

From
Johannes.Lichtenberger <>
To
"" <>
Date
2010-10-04T23:28:01Z
ID
<>
Thread
[Java] Create a new StAX parser...
Hello,

ok, I think the subject is a bit misleading. I wonder if there's a
better way to create a new StAX-Parser, which should be moved to the
event where another StAX-Parser currently is in a file.

I did the following, because I've found no method or constructor to
create a new EventReader out of another:

int level = 0;
boolean foundParsedElement = false;
mParser = createReader(null);
while (mParser.hasNext() && !foundParsedElement) {
  final XMLEvent xmlEvent = mParser.nextEvent();
  switch (xmlEvent.getEventType()) {
  case XMLStreamConstants.START_ELEMENT:
    level++;
    if (level == mLevelInToShredder &&
checkStAXElement((StartElement)xmlEvent, mElem)) {
      // Found corresponding start element.
      foundParsedElement = true;
    }
    break;
  case XMLStreamConstants.END_ELEMENT:
    level--;
    break;
  default:
    // Do nothing.
  }
}

Well, I'm using the code already, but I'm currently refactoring some code.

regards,
johannes
← Prev in month ← Prev in thread