split a xml line by line

devadam

New Member
I have a piece of xml code like below And I would read in this and split it by newline\[code\]<head> <name>states.opml</name> <Created>Tue, 15 Mar 2005 16:35:45 GMT</Created> <Modified>Thu, 14 Jul 2005 23:41:05 GMT</Modified> <owner>Dave Winer</owner> <Email>[email protected]</Email> <expansion>1, 6, 13, 16, 18, 20</expansion> <vertScrollState>1</vertScrollState> <windowTop>106</windowTop> <windowLeft>106</windowLeft> <windowBottom>558</windowBottom> <windowRight>479</windowRight> </head>\[/code\]my perl code:\[code\]my $xml=<STDIN>;my @head=split(/\n/,$xml);print length(@head);#output is 1...split is not working at all\[/code\]what i want is:what I want is a string array like this:\[code\]@head={<head>, <name>states.opml</name>, <Created>Tue, 15 Mar 2005 16:35:45 GMT</Created>, <Modified>Thu, 14 Jul 2005 23:41:05 GMT</Modified>, <owner>Dave Winer</owner>, <Email>[email protected]</Email>, <expansion>1, 6, 13, 16, 18, 20</expansion>, <vertScrollState>1</vertScrollState>, <windowTop>106</windowTop>, <windowLeft>106</windowLeft>, <windowBottom>558</windowBottom>, <windowRight>479</windowRight>, </head>}\[/code\]Can some one help? I know about XML::XMLin, but not allowed to use it.Thanks!
 
Back
Top