Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
<Name>ABC</Name><Address>Address1</Address><City>US</City>
in OUTFILE you want to parse with ending >
that way you would have 3 pairs of parsed data
(each tag set would require two parse variables)
then put them together with a literal > at the end of each with the newline char /.
and OMIT 1,3,EQ,' '
if your records have more than 3 tag sets,
then your logic would be different.
if you had a potential max of 5 tag sets per record / 10 of you records has 5, a few only 2 and the rest three.
don't know how parse works for data that is not there,
or what the results in the parse variable ($nn) will be if there is nothing to populate.
maybe it says something in the manual.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Indrajit_57,
As the DFSORT guys will be along later, now is the time to get your requirement set.
Do you want the solution for three tags, with the idea that you can apply it to as many as you want, or do you want a solution for three tags which usually will different values, or what.
Have a think, and do a good job of describing what you want, and what you will then do with the things, and if there is a possibility, some DFSORT will be woven for you, during working-hours in San Jose, California.
EDIT ENRICO.XMLTAGS.TXT Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 name
000002 address
000003 city
000004 zip
****** **************************** Bottom of Data ****************************
********************************* TOP OF DATA **********************************
XMLPARS - Started
tags read 4
text read 30
<address>addr1</address> address <address>addr1</address>
<address>addr1</address><city>city1</cit address <address>addr1</address>
<address>addr1</address><city>city1</cit city <city>city1</city>
<address>addr2</address> address <address>addr2</address>
<address>addr2</address><city>city2</cit address <address>addr2</address>
<address>addr2</address><city>city2</cit city <city>city2</city>
<address>addr3</address> address <address>addr3</address>
<address>addr3</address><city>city3</cit address <address>addr3</address>
<address>addr3</address><city>city3</cit city <city>city3</city>
<address>addr4</address> address <address>addr4</address>
<address>addr4</address><city>city4</cit address <address>addr4</address>
<address>addr4</address><city>city4</cit city <city>city4</city>
<address>addr5</address> address <address>addr5</address>
<address>addr5</address><city>city5</cit address <address>addr5</address>
<address>addr5</address><city>city5</cit city <city>city5</city>
<city>city1</city> city <city>city1</city>
<city>city2</city> city <city>city2</city>
<city>city3</city> city <city>city3</city>
<city>city4</city> city <city>city4</city>
<city>city5</city> city <city>city5</city>
<name>name1</name> name <name>name1</name>
<name>name1</name><address>addr1</addres name <name>name1</name>
<name>name1</name><address>addr1</addres address <address>addr1</address>
<name>name1</name><address>addr1</addres city <city>city1</city>
<name>name1</name><city>city1</city> name <name>name1</name>
<name>name1</name><city>city1</city> city <city>city1</city>
<name>name2</name> name <name>name2</name>
<name>name2</name><address>addr2</addres name <name>name2</name>
<name>name2</name><address>addr2</addres address <address>addr2</address>
<name>name2</name><address>addr2</addres city <city>city2</city>
<name>name2</name><city>city2</city> name <name>name2</name>
<name>name2</name><city>city2</city> city <city>city2</city>
<name>name3</name> name <name>name3</name>
<name>name3</name><address>addr3</addres name <name>name3</name>
<name>name3</name><address>addr3</addres address <address>addr3</address>
<name>name3</name><address>addr3</addres city <city>city3</city>
<name>name3</name><city>city3</city> name <name>name3</name>
<name>name3</name><city>city3</city> city <city>city3</city>
<name>name4</name> name <name>name4</name>
<name>name4</name><address>addr4</addres name <name>name4</name>
<name>name4</name><address>addr4</addres address <address>addr4</address>
<name>name4</name><address>addr4</addres city <city>city4</city>
<name>name4</name><city>city4</city> name <name>name4</name>
<name>name4</name><city>city4</city> city <city>city4</city>
<name>name5</name> name <name>name5</name>
<name>name5</name><address>addr5</addres name <name>name5</name>
<name>name5</name><address>addr5</addres address <address>addr5</address>
<name>name5</name><address>addr5</addres city <city>city5</city>
<name>name5</name><city>city5</city> name <name>name5</name>
<name>name5</name><city>city5</city> city <city>city5</city>
XMLPARS - Ended
READY
END
******************************** BOTTOM OF DATA ********************************
might not be the finakl solution,
but a strong Proof Of Concept of how
and demonstration of REXX parsing capabilities thru the use of the INTERPRET instruction
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Indrajit,
How you would (or if you could) do something like this with PARSE would depend on exactly what variations the records could have in terms of the pattern. If each record always starts with <tag1> and ends with </tagn> (e.g. not <tagx> in record and </tagx> in another record), you might be able to PARSE for each '><' pair in the record (up to the maximum number of pairs in a record) and break it between '>' and '<'. The last %n present would get the last tag pair (up to the end of the record) and %ns not present after that would be blanks (that is, not start with <) so they could be eliminated. So you wouldn't really need to code each specific tag name.
Quote:
but in this particular case given the number of tags involved a <programmatical> approach might be better
I tend to agree.
But if you want an actual DFSORT solution, show a much more detailed example of what your input records can look like, give the maximum number of tag pairs per record, etc.