1

Possible Duplicate:
JAXB: How to ignore namespace during unmarshalling XML document?

I am trying to unmarshal xml to java objects with JAXB. I have manually created the java bean classes which will be populated after unmarshalling (as I don't have any xsd for the xml). At runtime, I get 2 types of xml responses which I have to unmarshal. One case, the xml comes with out any namespace. And in the other cases, there is namespace declaration for the parent tag and there is namespace prefix before all the child tags.

I need to use the same set of classes for unmarshalling both types of xmls.

How is it possible? Is it possible to ignore the namespace while unmarshalling using JAXB?

Any suggestion?

Community
  • 1
  • 1
Surya
  • 494
  • 3
  • 11
  • 23

1 Answers1

3

You could use JAXB to unmarshal from StAX with a StreamReaderDelegate to strip off the namespace information. Below is a link to an article I wrote where I use this approach to do case insensitive unmarshalling:

bdoughan
  • 147,609
  • 23
  • 300
  • 400