LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2013, 12:01 PM   #1
elalexluna83
Member
 
Registered: Mar 2012
Posts: 55

Rep: Reputation: Disabled
Bash select lines from xml file


Hi guys, i have a xml file that has this info within
Code:
<fc:Entity id="uuid1a3286a-0139-1889-9bb3-c1e3ce91b9ca" protocolId="https://www.myplace.com/shop/b2b/"
        role="sp">
      <fc:DisplayName>BD-WC-B2B</fc:DisplayName>
      <fc:Description></fc:Description>
      <fc:ContactInformation>Cindy,Cook,cookc@us.myplace.com,**,**,**,**,CONTACT_TYPE_TECHNICAL</fc:ContactInformation>
      <fc:ProtocolEndpoints>
        <fc:ProtocolEndpoint endpoint="https://proxy1.myplace.com/shop/b2bR1LocDev/saml/receiver"
            type="SAML1.AssertionConsumerService"/>
      </fc:ProtocolEndpoints>
    </fc:Entity>
    <fc:Entity id="uuidbe218512-013a-19eb-a211-cbb284a9ebec" protocolId="https://kappa-2.myplace.com/shop/b2b/"
        role="sp">
      <fc:DisplayName>BizSim WebChannel B2B</fc:DisplayName>
      <fc:Description></fc:Description>
      <fc:ContactInformation>**,**,**,**,**,**,**,CONTACT_TYPE_TECHNICAL</fc:ContactInformation>
      <fc:ProtocolEndpoints>
        <fc:ProtocolEndpoint endpoint="https://proxy1.myplace.com/shop/b2bBizSim/saml/receiver"
            type="SAML1.AssertionConsumerService"/>
      </fc:ProtocolEndpoints>
    </fc:Entity
I want my script to only prints something like this, any help/hint to start with?

https://www.myplace.com/shop/b2b/
BD-WC-B2B
https://proxy1.myplace.com/shop/b2bR.../saml/receiver

https://kappa-2.myplace.com/shop/b2b/
BizSim WebChannel B2B
https://proxy1.myplace.com/shop/b2bBizSim/saml/receiver
 
Old 01-03-2013, 03:56 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Are you sure you need this to be done with bash? XML parsing requires significant text processing which is not at all well suited to bash. Even using a programming language that is much stronger at text processing, such as Perl, it is not recommended to process XML without the aid of a known-good library such as XML::Parser or other similar package.
--- rod.
 
Old 01-03-2013, 06:49 PM   #3
elalexluna83
Member
 
Registered: Mar 2012
Posts: 55

Original Poster
Rep: Reputation: Disabled
do you know how to do it using Perl?
 
Old 01-03-2013, 07:18 PM   #4
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Some you could check out is XMLStarlet at http://xmlstar.sourceforge.net/.

Lyle.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to strip some content from XML file. musther Programming 29 10-16-2021 10:23 AM
Getting Same Lines from File(BASH) eawedat Programming 23 09-13-2012 12:55 PM
[SOLVED] bash script problem, using zenity to file select m2t file for mplayer but don't work? davetesc Linux - Newbie 2 05-26-2012 06:49 PM
Basic bash script question re: file size or # of lines in a file the_fornicator Programming 6 09-03-2009 09:41 AM
BASH Scripting - printing select lines in a file bullfrog1870 Linux - Newbie 16 11-08-2006 09:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration