Sponsored Content
Full Discussion: · simerian · XML Extract
Top Forums Shell Programming and Scripting · simerian · XML Extract Post 42419 by Simerian on Wednesday 29th of October 2003 06:36:15 AM
Old 10-29-2003
Examples

Code:
<?xml version="1.0" encoding="LATIN1"?>
<DOCUMENT DocumentID="1">
	<EVENT Key="0" FileName="filename" FileSize="1" Method="create">
		<DATE>28102003</DATE>
		<TIME>110000</TIME>
	</EVENT>
	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">
		<DATE>29102003</DATE>
		<TIME>135600</TIME>
	</EVENT>
</DOCUMENT>

Extracting up to but not including <EVENT Key=”1”>: Use "document/event.key=1" "^"

<DOCUMENT DocumentID="1">
	<EVENT Key="0" FileName="filename" FileSize="1" Method="create">
		<DATE>28102003</DATE>
		<TIME>110000</TIME>

Extract up and including <EVENT Key=”1”>: Use "document/event.key=1" "-"

<DOCUMENT DocumentID="1">
	<EVENT Key="0" FileName="filename" FileSize="1" Method="create">
		<DATE>28102003</DATE>
		<TIME>110000</TIME>
	</EVENT>
	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">

Extracting from and including <EVENT Key=”1”>: Use “document/event.key=1" "+"

	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">
		<DATE>29102003</DATE>
		<TIME>135600</TIME>
	</EVENT>
</DOCUMENT>

Extracting from but not including <EVENT Key=”1”>: "document/event.key=1" "$"

		<DATE>29102003</DATE>
		<TIME>135600</TIME>
	</EVENT>
</DOCUMENT>

Extracting the whole of the <EVENT Key=”1”> element group: "document/event.key=1" "#"

	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">
		<DATE>29102003</DATE>
		<TIME>135600</TIME>
	</EVENT>

Extract to the last insertion point of <EVENT Key=”1”>: "document/event.key=1" "<"

<DOCUMENT DocumentID="1">
	<EVENT Key="0" FileName="filename" FileSize="1" Method="create">
		<DATE>28102003</DATE>
		<TIME>110000</TIME>
	</EVENT>
	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">
		<DATE>29102003</DATE>
		<TIME>135600</TIME>

Extracting from the last insertion point of <EVENT Key=”1”>: "document/event.key=1" ">"

	</EVENT>
</DOCUMENT>

Extracting the opening element for <EVENT Key=”1”>: "document/event.key=1" "@"

	<EVENT Key="1" FileName="filename" FileSize="3" Method="edit">

Extracting a specific attribute from <EVENT Key=”1”>: "document/event.key=1" "filesize"

	3

Multiple attributes can be specified using the form:

	"element.attribute=value/element.attribute=value/..."
or	"element.attribute=value.attribute=value/..."

Some of the more astute amongst you will have no doubt bemoaned the fact the script is currently entity name case-insensitive - which obviously breaks the XML standards. This can be rectified with a little code editing which I shall leave to the more adventurous of you.

HINT: Look for the use of toupper!
 

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

· simerian · Posting Issues

I have tried to post threads with attachments (i.e. for script submissions), however, the site reports that the files are over 1MB even when they are less than 10KB in size. Anybody else experiencing this issue or have any ideas? (2 Replies)
Discussion started by: Simerian
2 Replies

2. Shell Programming and Scripting

SED extract XML value

I have the following string: <min-pool-size>2</min-pool-size> When I pipe the string into the following code I am expcting for it to return just the value "2", but its just reurning the whole string. Why?? sed -n '/<min-pool-size>/,/<\/min-pool-size>/p' Outputting:... (13 Replies)
Discussion started by: ArterialTool
13 Replies

3. Shell Programming and Scripting

XML data extract

Hi all, I have the following xml document : <HEADER><El1>asdf</El1> <El2>3</El2> <El3>asad</El3> <El4>asasdf</El4> <El5>asdf</El5> <El6>asdf</El6> <El7>asdf</El7> <El8>A</El8> <El9>0</El9> <El10>75291028141917</El10> <El11>asdf</El11> <El12>sdf</El12> <El13>er</El13> <El14><El15>asdf... (1 Reply)
Discussion started by: nthed
1 Replies

4. Shell Programming and Scripting

sed extract from xml

I have an xml file that generally looks like this: "<row><dnorpattern>02788920</dnorpattern><description/></row><row><dnorpattern>\+ 44146322XXXX</dnorpattern><description/></row><row><dnorpattern>40XXX</dnorpattern><description/></row><row><dnorpattern>11</dn... (4 Replies)
Discussion started by: garboon
4 Replies

5. Shell Programming and Scripting

xml extract problem

I have looked at other responses and never was able to modify to work. data is: <?xml version="1.0"?> <note version="0.3" xmlns:link="http://beatniksoftware.com/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size" xmlns="http://beatniksoftware.com/tomboy"><title>recoll</title><text... (12 Replies)
Discussion started by: Klasform
12 Replies

6. Shell Programming and Scripting

Extract value from XML

I have a file like below <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

7. Shell Programming and Scripting

Extract Multivalue from XML

I have below attached xml file , how can I have my desired output as below. i/p file <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

8. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

9. Shell Programming and Scripting

Extract strings from XML files and create a new XML

Hello everybody, I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings.. The original XML files contain the source code for... (12 Replies)
Discussion started by: milano.churchil
12 Replies

10. Shell Programming and Scripting

Extract a value from an xml file

I have this XML file format and all in one line: Fri Dec 23 00:14:52 2016 Logged Message:689|<?xml version="1.0" encoding="UTF-8"?><PORT_RESPONSE><HEADER><ORIGINATOR>XMG</ORIGINATOR><DESTINAT... (16 Replies)
Discussion started by: mrn6430
16 Replies
XML::Handler::CanonXMLWriter(3) 			User Contributed Perl Documentation			   XML::Handler::CanonXMLWriter(3)

NAME
XML::Handler::CanonXMLWriter - output XML in canonical XML format SYNOPSIS
use XML::Handler::CanonXMLWriter; $writer = XML::Handler::CanonXMLWriter OPTIONS; $parser->parse(Handler => $writer); DESCRIPTION
"XML::Handler::CanonXMLWriter" is a PerlSAX handler that will return a string or write a stream of canonical XML for an XML instance and it's content. "XML::Handler::CanonXMLWriter" objects hold the options used for writing the XML objects. Options can be supplied when the the object is created, $writer = new XML::Handler::CanonXMLWriter PrintComments => 1; or modified at any time before calling the parser's `"parse()"' method: $writer->{PrintComments} = 0; OPTIONS
IOHandle IOHandle contains a handle for writing the canonical XML to. If an IOHandle is not provided, the canonical XML string will be returned from `"parse()"'. PrintComments By default comments are not written to the output. Setting comment to a true value will include comments in the output. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us SEE ALSO
perl(1), PerlSAX James Clark's Canonical XML definition <http://www.jclark.com/xml/canonxml.html> perl v5.12.1 2003-10-21 XML::Handler::CanonXMLWriter(3)
All times are GMT -4. The time now is 12:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy