Open ravenfeld opened 1 week ago
Perhaps the easiest thing to do is to enter the isNamespaceAware parameters?
private constructor() : this(XmlPullParserFactory.newInstance().apply { isNamespaceAware = true }.newPullParser())
So you mean that you have one file format with path trkpt/extensions/gpxtpx:TrackPointExtension/mtb:scale
and one with trkpt/gpxtpx:TrackPointExtension/mtb:scale
. Those are different (maybe compatible) file/xml formats. There are some directions you could go into:
I want to parse GPX files, but I don't know who exported the files and depending on the site there is data added in the extension. I don't want to read them, but this could cause a crash.
@ravenfeld You can configure your policy to handle unknown tags/attributes (either by mapping them to a field, ignore them, log them, or throw an exception). That should deal with crashes. Alternatively it is possible to have @XmlValue List<Element>
and XmlOtherAttributes
to capture the unknown children in a generic way (rather than ignoring them). You can also use either Element
or CompactFragment
as type of an "extension" child and that will just contain the content of that tag without caring about the specifics.
What neither option does is give you access to data inside the extension in a typesafe way.
Hello, I'm trying to make a GPX file parser but I'm getting stuck because some sites send this style of tag. At the moment I don't need the information in the
extension
but it is still read and so themtb:scale
line crashes.Is it possible for the line to ignore the inside of a tag?