如何使用属性删除XML元素中前缀和值之间的多余空格?

How to remove extra whitespace between prefix and value in XML element using attributes?

提问人:AdnanKattekaden 提问时间:6/16/2023 最后编辑:chorobaAdnanKattekaden 更新时间:6/16/2023 访问量:50

问:

我有一个XML代码片段,如下所示:

<element id="billNoPre" class="LabelText" value="Reference:0-" field="">
    <matrix x="0" y="0" height="10" scaleX="1" scaleY="1" rotation="0" />
    <style fontStyle="normal" lineHeight="100%" textAlign="right" fontSize="10" fontWeight="bold" fontFamily="calibriEmbedded" />
</element>

<element id="billNo" class="LabelText" prefixElement="billNoPre" value="00.00" field="billNumber">
    <matrix x="440" y="15" height="15" scaleX="1" scaleY="1" rotation="0" />
    <style fontStyle="normal" lineHeight="100%" textAlign="right" fontWeight="bold" fontSize="10" fontFamily="calibriEmbedded" />
</element>

当我检索 billNo 元素的值时,它在前缀“Reference:0-”和实际值“4564564564”之间包含额外的空格。当前输出是“Reference:0- 4564564564”,但我希望它是“Reference:0-4564564564”,没有任何额外的空格。

如何修改代码以实现所需的输出?

Java XML 解析 ERP

评论

4赞 choroba 6/16/2023
价值从何而来?它不存在于任何位置的 XML 中。另外,你用什么代码来提取它?
0赞 tquadrat 6/16/2023
问题出在输出上,而不是在输入数据上。仅取自您的描述的内容。但是,如果您想要有关如何解决此问题的解释,则需要显示您使用的代码。

答: 暂无答案