following is my expected req xml to be formed
<custom key="234234e324e4">
<document name="sample" location="http://example.com">
</document>
</custom>
to make this xml i have used following go code
type Documentxml struct {
XMLName xml.Name `xml:"document"`
Name string `xml:"name,attr"`
Location string `xml:"location,attr"`
}
type DeleteXml struct {
XMLName xml.Name `xml:"custom"`
Key string `xml:"key,attr"`
Document Documentxml `xml:"document"`
}
and following code to insert values into it
var requestxml DeleteXml
requestxml.Key = "12321321"
requestxml.Document.Name = "sample"
requestxml.Document.Location = "www.//sample.com"
bytexml, err := xml.Marshal(&requestxml)
client := &http.Client{}
url := "http://localhost:8080/searchblox/api/rest/docdelete"
// build a new request, but not doing the POST yet
req, err := http.NewRequest("POST", url, bytes.NewBuffer(bytexml))
if err != nil {
fmt.Println(err)
}
req.Header.Add("Content-Type", "application/xml; charset=utf-8")
// now POST it
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
}
fmt.Println(resp)
but here request formed is not as i expected to be formed request xml formed is: {{ } 12321321{{ } sample www.//sample.com}} please suggest what is going wrong here
</div>