FAQ
I am working with a funky RFC that requires a dyanmic tag in the form of
the following

      <rpc message-id="101"
           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
        <lock>
          <target>
            <running/>
          </target>
        </lock>
      </rpc>



Where <running/> can be any dynamic name.


I will argue that this is not a proper use of XML but it is what I have to work with. Is there an easy way (or a way at all) to have a dynamic tag and marshal it to XML. Today i have the following:


http://play.golang.org/p/81FKt_Qiu6


But obviously right now my target variable is not being set as a tag.


Any help?


- Brandon

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Volker Dobler at Sep 3, 2013 at 12:55 pm

    Am Dienstag, 3. September 2013 11:33:01 UTC+2 schrieb Brandon Bennett:
    I am working with a funky RFC that requires a dyanmic tag in the form of
    the following

    <rpc message-id="101"
    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <lock>
    <target>
    <running/>
    </target>
    </lock>
    </rpc>



    Where <running/> can be any dynamic name.
    If this is all of the XML you have to generate: Why not just fmt.Printf the
    whole stuff?

    V.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Robert Johnstone at Sep 3, 2013 at 1:22 pm
    You should look closely at the documentation for the function xml.Marshal.
    There is an attribute "innerxml" that I believe will provide what you need.

    On Tuesday, 3 September 2013 05:33:01 UTC-4, Brandon Bennett wrote:

    I am working with a funky RFC that requires a dyanmic tag in the form of
    the following

    <rpc message-id="101"
    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <lock>
    <target>
    <running/>
    </target>
    </lock>
    </rpc>



    Where <running/> can be any dynamic name.


    I will argue that this is not a proper use of XML but it is what I have to work with. Is there an easy way (or a way at all) to have a dynamic tag and marshal it to XML. Today i have the following:


    http://play.golang.org/p/81FKt_Qiu6


    But obviously right now my target variable is not being set as a tag.


    Any help?


    - Brandon
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Martin Schnabel at Sep 4, 2013 at 11:01 am

    On 09/03/2013 11:33 AM, Brandon Bennett wrote:
    I am working with a funky RFC that requires a dyanmic tag in the form of
    the following

    <rpc message-id="101"
    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <lock>
    <target>
    <running/>
    </target>
    </lock>
    </rpc>



    Where <running/> can be any dynamic name.


    I will argue that this is not a proper use of XML but it is what I have to work with. Is there an easy way (or a way at all) to have a dynamic tag and marshal it to XML. Today i have the following:


    http://play.golang.org/p/81FKt_Qiu6
    you have already solved the problem for the lock element (with innerxml
    and xml.Name). you can do the same for the running element:

    with xml.Name:
      http://play.golang.org/p/of9y2UCt0a

    with ,innerxml
      http://play.golang.org/p/ReCW-FvdWR

    if the lock element is not dynamic you can skip one struct
      http://play.golang.org/p/5LthfE1f0o

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 3, '13 at 12:23p
activeSep 4, '13 at 11:01a
posts4
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase