0

Please find below xml format where namespace is coming in end tags as well

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<report xmlns="urn:nonstandard:****">
<headers/>
<report_details/>
</report xmlns="urn:nonstandard:****">

Please check below code snippet which i'm using

@XmlRootElement(name = "report", 
namespace = "xmlns=urn:nonstandard:****")
@XmlAccessorType(XmlAccessType.FIELD)
public class ReportVo {
        @XmlElement(name="header")
    private HeaderVo headerVo;
    
    
    @XmlElement(name="report_details")
    private ReportDetailsVO reportDetailsVo;
}

and i'm expecting my xml should generate like below

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<report xmlns="urn:nonstandard:****">
<headers/>
<report_details/>
</report>

  • Hello! I suggest you try to change `namespace = "xmlns=urn:nonstandard:****"` to `namespace = "urn:nonstandard:****"` – PawMaw Jul 14 '23 at 13:33
  • Thank you @PawMaw . sorry i was new in using xml namespace thing, it worked and its coming as **xmlns:ns2="urn:nonstandard:mfiu-ttr"**. How can i remove ns2 after xmlns – AnilSrinivas Muddineni Jul 15 '23 at 09:00
  • I searched some topics and found 2 solutions. One of them is try to add attribute `prefix=""` to your report tag. If it wont help go to this question https://stackoverflow.com/questions/16589600/remove-ns2-as-default-namespace-prefix – PawMaw Jul 15 '23 at 19:18
  • 1
    I found this similar to my question and it helps https://stackoverflow.com/questions/4312572/jaxb-generated-xml-problem-with-root-element-prefix – AnilSrinivas Muddineni Jul 17 '23 at 05:53

0 Answers0