Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

HALP PLIZ!!!

Name: A fag 2011-05-31 18:03

Dear faggots:

First, some background
I just have XML::Parser and XML::Writer available, nothing else.
Language is perl 5.8.8

I have this XML. I have succesfully read this in memory, modified it, and now i have to write it back.

The XML in need to write:

<userdef depends="" src="CustomDef">
    <port>
        <Group NTYPE="ROOT" NAME="DPV" TYPE="TOP" GID="ID_T1234">
            <Group NAME="TEST_DPV" TYPE="BOOK" GID="ID_T9999">
                <Position RANKING="0" POS="100" SEC_ID="BD-TEST-1"/>
                <Position RANKING="0" POS="200" SEC_ID="BD-TEST-2"/>
            </Group>
        </Group>
    </port>
</userdef>


The data structure:

$VAR1 = [
          'userdef',
          [
            {
              'src' => 'CustomDef',
              'depends' => ''
            },
            0,
            '
    ',
            'port',
            [
              {},
              0,
              '
        ',
              'Group',
              [
                {
                  'NAME' => 'DPV',
                  'GID' => 'ID_T1234',
                  'TYPE' => 'TOP',
                  'NTYPE' => 'ROOT'
                },
                0,
                '
            ',
                'Group',
                [
                  {
                    'NAME' => 'TEST_DPV',
                    'GID' => 'ID_T9999',
                    'TYPE' => 'BOOK'
                  },
                  0,
                  '
                ',
                  'Position',
                  [
                    {
                      'RANKING' => '0',
                      'SEC_ID' => 'BD-TEST-1',
                      'POS' => '100'
                    }
                  ],
                  0,
                  '
                ',
                  'Position',
                  [
                    {
                      'RANKING' => '0',
                      'SEC_ID' => 'BD-TEST-2',
                      'POS' => '200'
                    }
                  ],
                  0,
                  '
            '
                ],
                0,
                '
        '
              ],
              0,
              '
    '
            ],
            0,
            '
'
          ]
        ];


I can't make a recursive algorithm to write this?

Care to help? If you do, i will donate 10 bucks to the FSF.

Name: Anonymous 2011-05-31 18:17

>>3
You can't just

$tag = shift @xml;
%attribs = shift @xml;
$res = '<$tag ' + stringize_attribs(%attribs) /* for each $key,$value: '$key="$value"' */;
if (not_empty(@xml)) return $res + '/>';
else map(this_function,@xml[2:])


Not valid Perl code (I think), but that's the point.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List