Loading ...
Sorry, an error occurred while loading the content.

nexted XML output under single node from while loop

Expand Messages
  • ask4uk
    Hello, I am trying to produce XML output of the form: string string
    Message 1 of 2 , Feb 18, 2004
    • 0 Attachment
      Hello,

      I am trying to produce XML output of the form:

      <attributes>
      <RadiusAttribute>
      <type>string</type>
      <value>string</value>
      </RadiusAttribute>
      <RadiusAttribute>
      <type>string</type>
      <value>string</value>
      </RadiusAttribute>
      </attributes>

      I am using the code snippet below, based on the various samples in
      this list:

      while (($name, $value) = $p->get_attr_val_n($i++))
      {
      #push(@args, SOAP::Data->name('attribute' => [$name,
      $value]));


      push(@args,( SOAP::Data->name("attributes"=>
      \SOAP::Data->name
      ("RadiusAtrtibute"=>
      \SOAP::Data->value(SOAP::Data->name
      ("type"=>$name)),
      \SOAP::Data->value(SOAP::Data->name
      ("value"=>$value))
      )
      )));
      }

      However, this creates a separate "attributes" node for each iteration
      of the loop (fairly obviously, when you think about it...) and I only
      want one attributes node with multiple children. I have scoured the
      net without much luck on this one and am now banging my head on the
      desk. Any thoughts gratefully received!

      Regards

      Jonathan
    • jpeyser
      Try for (1..2) { push(@args,( SOAP::Data- name( RadiusAttribute = SOAP::Data- value( SOAP::Data- name( type = $name), SOAP::Data- name( value = $value) ))));
      Message 2 of 2 , Feb 19, 2004
      • 0 Attachment
        Try

        for (1..2) {
        push(@args,(
        SOAP::Data->name("RadiusAttribute"=> \SOAP::Data->value(
        SOAP::Data->name("type"=>$name),
        SOAP::Data->name("value"=>$value)
        ))));
        }

        $args = SOAP::Data->name("attributes"=> \SOAP::Data->value(@args));

        Jonathan

        --- In soaplite@yahoogroups.com, "ask4uk" <jon@a...> wrote:
        > Hello,
        >
        > I am trying to produce XML output of the form:
        >
        > <attributes>
        > <RadiusAttribute>
        > <type>string</type>
        > <value>string</value>
        > </RadiusAttribute>
        > <RadiusAttribute>
        > <type>string</type>
        > <value>string</value>
        > </RadiusAttribute>
        > </attributes>
        >
        > I am using the code snippet below, based on the various samples in
        > this list:
        >
        > while (($name, $value) = $p->get_attr_val_n($i++))
        > {
        > #push(@args, SOAP::Data->name('attribute' => [$name,
        > $value]));
        >
        >
        > push(@args,( SOAP::Data->name("attributes"=>
        > \SOAP::Data->name
        > ("RadiusAtrtibute"=>
        > \SOAP::Data->value(SOAP::Data->name
        > ("type"=>$name)),
        > \SOAP::Data->value(SOAP::Data->name
        > ("value"=>$value))
        > )
        > )));
        > }
        >
        > However, this creates a separate "attributes" node for each
        iteration
        > of the loop (fairly obviously, when you think about it...) and I
        only
        > want one attributes node with multiple children. I have scoured the
        > net without much luck on this one and am now banging my head on the
        > desk. Any thoughts gratefully received!
        >
        > Regards
        >
        > Jonathan
      Your message has been successfully submitted and would be delivered to recipients shortly.