in reply to XML::Writer and namespaces

Ok, I've find out to get the namespace-declaration in the root-element: <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

I need to set $writer->forceNSDecl($ns1); before writing the first tag

But how get I the "xsi:" - Prefix on the attribute?

Replies are listed 'Best First'.
Re^2: XML::Writer and namespaces
by Mr. Ed (Initiate) on Dec 21, 2016 at 13:59 UTC
    And finally ... here is the solution for issue 2) $writer->emptyTag("node", ([$ns1,"nil"] => "true")); makes my day: <node xsi:nil="true" />

    You have to read the perldoc very carefully, The NAMESPACES-section says:

    ... then the module will accept two-member array reference in the place of element and attribute names ...
Re^2: XML::Writer and namespaces
by Anonymous Monk on Dec 04, 2019 at 15:02 UTC
    Hi, I want to ask if there is any metho other than forceNSDecl to add namespace? in case if I want to add an attribute after the namespace?