Re: help with html table (nested for-each/keys/matched template)
- From: Jürgen Kahrs <Juergen.KahrsDELETETHIS@xxxxxxxxx>
- Date: Sun, 18 Dec 2005 16:26:12 +0100
rick wrote:
> code them. I recognize that the xml structure is a little awkward but
> that's what I have to work with. Thanks in advance for any
> suggestions.
You dont need XSL for such a trivial data extraction.
The following script in xmlgawk will do all the data
extraction described:
BEGIN { XMLMODE=1 }
XMLCHARDATA { data = $0 }
XMLENDELEM == "displayName" { name = data }
XMLENDELEM == "uri" { uri[name] = data }
XMLENDELEM == "resource_description" { split(data, d); dsc[d[1]] = data }
END {
for (n in uri) {
print uri[n] "\t" n "\t" dsc[n]
}
}
When running the script, you will get the result:
gawk -lxml -f artifact.awk artifact.xml
location of file1 file1.doc file1.doc
description
location of file2 file2.doc file2.doc
description
Notice the line break in the output, which are caused by
your XML data. By the way, there is a bug in your XML data.
> <artifact>
> <file_name>file2.doc</file_name>
> <resource_description>file1.doc
here: ^^^^^^^^
> description</resource_description>
> </artifact>
.
- References:
- Prev by Date: for-each on atomic sequence
- Next by Date: Re: for-each on atomic sequence
- Previous by thread: help with html table (nested for-each/keys/matched template)
- Next by thread: Re: help with html table (nested for-each/keys/matched template)
- Index(es):
Relevant Pages
|