LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-24-2015, 03:15 AM   #1
SuKHI
LQ Newbie
 
Registered: Dec 2007
Posts: 14

Rep: Reputation: 0
extract node value from soap response


Hi,

I have one soap xml response and it contains repeating node name.

sample as below:

Code:
<ax279:nodes xsi:type="ax277:ChildIdentifierList">
               <ax277:id>3</ax277:id>
               <ax277:name>test</ax277:name>
               <ax277:children xsi:type="ax277:EntityIdentifier">
                  <ax277:id>9</ax277:id>
                  </ax277:children>
               <ax277:children xsi:type="ax277:EntityIdentifier">
                  <ax277:id>10</ax277:id>
                  <ax277:name>hello.world</ax277:name>
               </ax277:children>
            </ax279:nodes>
I need to extract <ax277:name>test</ax277:name> value based on app name hello.world from xml.

But issue is hello.world keep repeating under other tags too.
And tag name <ax277:name> also repeating.
If it was only one then I would have done with awk or grep or sed.

But still there is problem:
I used grep as below:
Code:
grep -oPm1 "(?<=<ax277:name>)[^<]+" node.xml
its only returning me first occurred value under that tag.

Then i tried with awk, it has returned all the values w.r.t that tag.
Code:
awk -F "[><]" '/ax277:name/{print $3}' node.xml
Can I pass both parent tag name with child tag to get single value?

something like: awk -F "[><]" '/ax279:nodes/ax277:name/{print $3}' node.xml

i tried above but again its syntax error.

Any idea?

Last edited by SuKHI; 12-24-2015 at 03:16 AM.
 
Old 12-24-2015, 10:48 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,104

Rep: Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146Reputation: 1146
To be honest, I don't understand what you want to achieve. If you want to extract a line named <ax277:name>test</ax277:name>, why don't you grep for it? Or what is it exactly you want to extract? What does hello.world have to do with it?

Regarding the syntax error: You use this string as a pattern -
Code:
/ax279:nodes/ax277:name/
You can't have a pattern with three slashes, except if you quote the middle one. Therefore, syntax error.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
rhel 2 node cluster: resources do not move to second node when node halted tapuhi Linux - Software 1 03-01-2015 11:41 AM
node recovery when the node becomes fault by using another node to replace it jerinc Linux - Wireless Networking 0 02-21-2014 06:44 PM
How to transfer the services from node 1 to node 2 ,if node 1 is directly turned off sankarg304 Linux - Server 1 12-12-2012 11:06 AM
php / SOAP - is it possible to return many values in a soap request? eantoranz Programming 1 04-25-2012 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration