Extract node value from soap response


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract node value from soap response
# 1  
Old 12-24-2015
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?
# 2  
Old 12-24-2015
From your description I can't tell what output you are hoping your awk script will produce.

I don't see any XML tags for an app name. What makes hello.world an app name? And if your XML identifies hello.world as an app name (with the <ax277:name> tag), why isn't test an app name too (from <ax277:name>test</ax277:name>)?
# 3  
Old 12-24-2015
Combining identification of both - what you call - parent and child tag could be done like
Code:
awk -F "[><]" '
/ax279:nodes/   {TR = 1}
TR &&
/ax277:name/    {print $3
                 TR = 0
                }
' file
test

But, as you can see, that wouldn't yield your desired result, as there are multiple name tags under the target parent. How would you discriminate "test" from "hello.world"?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. HP-UX

Mount FIle systems from node-1 onto node-2

Hi, We have HP UX service guard cluster on OS 11.23. Recently 40+ LUNs presented to both nodes by SAN team but I was asked to mount them on only one node. I created required VGs/LVs, created VxFS and mounted all of them and they are working fine. Now client requested those FS on 2nd node as... (4 Replies)
Discussion started by: prvnrk
4 Replies

2. Homework & Coursework Questions

Accessing one UNIX node from another node of the same server

Hi Experts, I am in need of running a script from one node say node 1 via node 2. My scheduling tool dont have access to node2 , so i need to invoke the list file from node1 but the script needs to run from node2. because the server to which i am hitting, is having access only for the node... (5 Replies)
Discussion started by: arun1377
5 Replies

3. Web Development

SOAP::Lite question

I have setup web service requests using SOAP::Lite. I include the following entries which have been assigned, like the uri, protocol, fully qualified dns name, port, path, realm and pw. I also assign header information eval { my $soap = SOAP::Lite->new( uri => $self->{uri}, ... (0 Replies)
Discussion started by: islanderman
0 Replies

4. Shell Programming and Scripting

SOAP module in perl

Hi, I have executed the below perl code to check whether SOAP module is working or not. #!/usr/bin/perl use SOAP::Transport::HTTP; print "Hai"; But I got the below error message: Can't locate SOAP/Transport/HTTP.pm in @INC (@INC contains:... (2 Replies)
Discussion started by: liyakathali
2 Replies

5. Solaris

SVM metaset on 2 node Solaris cluster storage replicated to non-clustered Solaris node

Hi, Is it possible to have a Solaris cluster of 2 nodes at SITE-A using SVM and creating metaset using say 2 LUNs (on SAN). Then replicating these 2 LUNs to remote site SITE-B via storage based replication and then using these LUNs by importing them as a metaset on a server at SITE-B which is... (0 Replies)
Discussion started by: dn2011
0 Replies

6. Shell Programming and Scripting

Soap client script

Hi everybody, I`d llike to know if it is possible to create a script that call a specific soap method and collect the response time of this method. Can someone give some tips and examples ? Thank you so much ! (0 Replies)
Discussion started by: robdcb
0 Replies

7. Programming

SOAP Client..!

Hi, Can anybody provide me a simple SOAP client in C/C++ ..? Thanks in advance....!! (1 Reply)
Discussion started by: Kattoor
1 Replies

8. Programming

Tcl - SOAP Problem

Hi, Im working with client side Tcl implementation on unix box of web services, to login to a tool with web service method written in C# on windows box and it is accessed by its link from the browser on unix box. Sorry that i have hidden the original names for security reasons. Using... (0 Replies)
Discussion started by: SankarV
0 Replies

9. Solaris

no SOAP encoding under unix?

Under Unix however we had many many many many problems. We had to use Ansi2utf8(), repstr() and XMLval() to prevent "Invalid token" errors. And because we didn't know what the raw XML result was, it allways was a big problem to find the cause of it. (0 Replies)
Discussion started by: devotedsinner
0 Replies
Login or Register to Ask a Question