<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic script to search an xml file and output all sections containing input string..... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674032#M41853</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I'm looking for a way to query an xml file for a particular property with content such as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;9&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;6&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The result of the query for &lt;BR /&gt;&lt;BR /&gt;script.sh 12345&lt;BR /&gt;&lt;BR /&gt;for example would be &lt;BR /&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;BR /&gt;How could this be done with sed/awk and other standard tools!&lt;BR /&gt;&lt;BR /&gt;Thanks for any help suggestions.&lt;BR /&gt;Regards,&lt;BR /&gt;Bill</description>
    <pubDate>Thu, 12 Aug 2010 12:10:39 GMT</pubDate>
    <dc:creator>Bill McNAMARA_1</dc:creator>
    <dc:date>2010-08-12T12:10:39Z</dc:date>
    <item>
      <title>script to search an xml file and output all sections containing input string.....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674032#M41853</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I'm looking for a way to query an xml file for a particular property with content such as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;9&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;6&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The result of the query for &lt;BR /&gt;&lt;BR /&gt;script.sh 12345&lt;BR /&gt;&lt;BR /&gt;for example would be &lt;BR /&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;BR /&gt;How could this be done with sed/awk and other standard tools!&lt;BR /&gt;&lt;BR /&gt;Thanks for any help suggestions.&lt;BR /&gt;Regards,&lt;BR /&gt;Bill</description>
      <pubDate>Thu, 12 Aug 2010 12:10:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674032#M41853</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2010-08-12T12:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: script to search an xml file and output all sections containing input string.....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674033#M41854</link>
      <description>This one works for me:&lt;BR /&gt;$ cat x.sh&lt;BR /&gt;#! /bin/sh&lt;BR /&gt;awk "BEGIN {RS=\"\"} /.*$1.*/ {printf \$0\"\"} END {printf \"\n\"}" $2&lt;BR /&gt;$&lt;BR /&gt;$ ./x.sh 12345 x.x&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;$</description>
      <pubDate>Thu, 12 Aug 2010 16:20:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674033#M41854</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2010-08-12T16:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: script to search an xml file and output all sections containing input string.....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674034#M41855</link>
      <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;# cat ./myfilter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pattern = shift or die;&lt;BR /&gt;undef $/;&lt;BR /&gt;my $xml = &lt;DATA&gt;;&lt;BR /&gt;for ( split( /&lt;CDR&gt;/, $xml ) ) {&lt;BR /&gt;    print "&lt;CDR&gt;", $_ if m/=$pattern&amp;gt;/;&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./myfilter 12345 file&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;5&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;CDR&gt;&lt;BR /&gt;&lt;ADDRESS&gt;&lt;/ADDRESS&gt;&lt;BR /&gt;&lt;RESULT&gt;91&lt;/RESULT&gt;&lt;BR /&gt;&lt;/CDR&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/CDR&gt;&lt;/CDR&gt;&lt;/DATA&gt;</description>
      <pubDate>Thu, 12 Aug 2010 19:58:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674034#M41855</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-08-12T19:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: script to search an xml file and output all sections containing input string.....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674035#M41856</link>
      <description>Hi,&lt;BR /&gt;Great thanks for your rapid answers.&lt;BR /&gt;James, I got an error with your script with the input.xml shown above...&lt;BR /&gt;&lt;BR /&gt;My perl isn't good enough to correct it yet!&lt;BR /&gt;&lt;BR /&gt;[root@oces01 scripts]# ./searchCDR.2.sh 12345 cdr.xml&lt;BR /&gt;Name "main::DATA" used only once: possible typo at ./searchCDR.2.sh line 6.&lt;BR /&gt;readline() on unopened filehandle DATA at ./searchCDR.2.sh line 6.&lt;BR /&gt;Use of uninitialized value in split at ./searchCDR.2.sh line 7.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Aug 2010 03:47:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674035#M41856</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2010-08-13T03:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: script to search an xml file and output all sections containing input string.....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674036#M41857</link>
      <description>Hi (again) Bill:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; James, I got an error with your script with the input.xml shown above...&lt;BR /&gt;&lt;BR /&gt;Yes, my apologies.  Change the line that reads:&lt;BR /&gt;&lt;BR /&gt;my $xml = &lt;DATA&gt;;&lt;BR /&gt;&lt;BR /&gt;...to be:&lt;BR /&gt;&lt;BR /&gt;my $xml = &amp;lt;&amp;gt;;&lt;BR /&gt;&lt;BR /&gt;The use of &lt;DATA&gt; allowed me to include your actual data as a part of the script by adding it at the script's end with the prepended line '__DATA__'.  When I dropped this I meant to make the change above to enable one or more files to be read from the command line.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/DATA&gt;&lt;/DATA&gt;</description>
      <pubDate>Fri, 13 Aug 2010 11:31:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-search-an-xml-file-and-output-all-sections-containing/m-p/4674036#M41857</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-08-13T11:31:12Z</dc:date>
    </item>
  </channel>
</rss>

