General discussion

Locked

Unix Script (Very URGENT)

By avazquez65 ·
I need to create a script shell to select some information from a XML source file, and I do not how to do it!!>

This is the XML source file:

<?xml version="1.0" encoding="UTF-8" ?>
- <res:FormalIDNotification xmlns:res="http://www.url.com" xmlns:xsi="http://www.xxx.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.url.com FormalID_DataTypes.xsd">
- <Section 1>
- <AddressInfo>
<ContactName>first last</ContactName>
<CompanyName>company</CompanyName>
<AddressLine1>addr1</AddressLine1>
<AddressLine2>addr22222</AddressLine2>
<AddressLine3>addr3333</AddressLine3>
<City>Brisbane</City>
<PostalCode>000</PostalCode>
<CountryCode>AU</CountryCode>
<PhoneNumber>12345</PhoneNumber>
<PhoneExtension>123</PhoneExtension>
<FaxNumber>12345</FaxNumber>
<Email>email@rr.com</Email>
</AddressInfo>
- <OtherInfo>
<SiteID>I7560</SiteID>
</OtherInfo>
</Importer>
- <Section 2>
- <AddressInfo>
<ContactName>brazil1</ContactName>
<CompanyName>ggh</CompanyName>
<AddressLine1>rrtrt</AddressLine1>
<City>sape</City>
<PostalCode>58340</PostalCode>
<CountryCode>BR</CountryCode>
<PhoneNumber>67778879</PhoneNumber>
<Email>gghj@yyy.com</Email>
</AddressInfo>


I need to select just part of the information, Example:

From the section 1, I need to get first last from label ContactName and company from the label CompanyName or can be anyone from the section 1.

Same case for the section 2


Thank you for your help


Best Regards

Aurelio Vazquez Alejo
avazquez65@yahoo.com

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by cpfeiffe In reply to Unix Script (Very URGENT)

Many ways. You can use awk, sed with regular expressions, perl, etc. I think cut will be the simplest if you don't have a lot of shell scripting experience. Here is a sample:
grep ContactName xmlfilename |cut -d\> -f2 |cut -d\< -f1

The result will be 'first last'.

Collapse -

by avazquez65 In reply to Unix Script (Very URGENT)

I have oe more comment!!

I have two <ContactName>, the first one in the first section 1 and the second in section 2.

How can I get them separetly.

Thann you for your help

Best Regards

Collapse -

by avazquez65 In reply to Unix Script (Very URGENT)

This question was closed by the author

Back to Linux Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums