Question:

I need help with Grep on SunOS

by  |  earlier

0 LIKES UnLike

I need to use grep to single out the latitude and logitude from this

<?xml version="1.0"?><SearchResults><Success>t... IP Location</Method></SearchResults>

I cant figure out how to single out the 2 numbers in to two seprate variables.

Thanks!

 Tags:

   Report

1 ANSWERS


  1. Perl may be the answer for you. Sorry your XML got mangled, I mad some guesses as to what it would be like:

    &lt;?xml version=&quot;1.0&quot;?&gt;&lt;SearchResults&gt;&lt;Success&gt;&lt;...

    I&#039;m guessing that your XML is all on one line (is this XML-RPC?), but I don&#039;t think it matters:

    $ cat your.txt | perl -lne &#039;print for /&lt;latitude&gt;(.*)&lt;\/latitude&gt;/g&#039;

    37.857713

    $ cat test.txt | perl -lne &#039;print for /&lt;longitude&gt;(.*)&lt;\/longitude&gt;/g&#039;

    -122.544544

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.