我目前正在尝试获取xmlns的值。我需要验证xml文件。我使用Jackson-dataformat-xml将xml文件反序列化为对象。到目前为止,我还没有找到获得这个价值的方法。
@JacksonXmlProperty(isAttribute = true)似乎不适用于xmlns。
xml
<Document xmlns="urn:...">
...
</Document>Java
@Data
public class Document {
@JacksonXmlProperty(isAttribute = true)
private String xmlns;
}据我所知,xmlns不是作为属性公开的。有什么能让我得到杰克逊的价值的吗?
发布于 2021-10-11 19:53:20
xmlns值是命名空间声明。它不是属性,而是元数据,因此解析器不会将它们公开为属性。
https://stackoverflow.com/questions/69530946
复制相似问题