How to deal with namespaces?
Closed this issue · 4 comments
It is unclear to me how to create Xml with namespaces.
For example:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <IndienenBerichtResponse xmlns="http://schemas.vecozo.nl/berichtuitwisseling/v3"> <IndienenBerichtResult> <ConversatieId xmlns="http://schemas.vecozo.nl/berichtuitwisseling/messages/v3">fc6d5c90-5630-4270-aba2-bc1be7936502</ConversatieId> <TraceerId xmlns="http://schemas.vecozo.nl/berichtuitwisseling/messages/v3">fc6d5c90-5630-4270-aba2-bc1be7936502</TraceerId> </IndienenBerichtResult> </IndienenBerichtResponse> </s:Body> </s:Envelope>
How to add s as a namespace using generate?
One approach, hard-coding the prefix - is
iex(1)> XmlBuilder.generate({:"s:Envelope", [{:"xmlns:s", "http://schemas.xmlsoap.org/soap/envelope/"}], []})
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"/>"
That's what I did, and it works nicely, I just thought I missed some option or something.
So if this is the way, then I will do it as such.
Thx for the reply.
@eddy147 the solution @devstopfix mentioned is correct.
I've updated the README
to include an example. https://github.com/joshnuss/xml_builder#namespaces
Thx for the update in the README.