Hi Ssupun,

Is this a better way as per coding standards.
Or, the methodology I have been using is more effective.

In broader terms ,

Sample xml
----------
<operation>
<in1>1</in1>
<in2>2</in2>
</operation>

I will first need to get the parent element, and then all the children and loop 
thru it.

axiom_element_get_child_elements creates a list. And what does 
axiom_child_element_iterator_has_next do ?

Keeping the above mentioned xml, if you can tell me in a few lines of code, 
which will prevent me from running into the "Segmentation issue", it would be 
great.

Thanks
Ramesh.


--- On Tue, 4/11/08, Supun Kamburugamuva <[EMAIL PROTECTED]> wrote:

> From: Supun Kamburugamuva <[EMAIL PROTECTED]>
> Subject: Re: Some quick Axis2C help required
> To: "Apache AXIS C User List" <axis-c-user@ws.apache.org>, [EMAIL PROTECTED]
> Date: Tuesday, 4 November, 2008, 4:47 PM
> Here is a code sample for using the child element iterator.
> You can find
> this kind of code all over the axis2/C source.
> 
> axiom_child_element_iterator_t *ci = NULL;
> 
> if ((ci = axiom_element_get_child_elements(element, env,
> node)) != NULL)
> {
>         axiom_element_t *ce = NULL;
>         axiom_node_t *cn = NULL;
>         while(AXIS2_TRUE ==
> axiom_child_element_iterator_has_next(ci, env))
>         {
>             cn = axiom_child_element_iterator_next(ci,
> env);
>             /* chile element do what ever you want */
>             ce = axiom_node_get_data_element(cn, env);
> 
>         }
> }
> 
> Supun.
> 
> On Tue, Nov 4, 2008 at 3:29 PM, ramesh Gopal
> <[EMAIL PROTECTED]>wrote:
> 
> >
> >
> > Hi Shankar,
> >
> > Could you give me a better solution which achieves
> this ...
> >
> > Basically, I want to read all the child nodes (for a
> node) and get the
> > values.
> >
> > I have tried using axiom_element_get_child_elements or
> > axiom_element_get_children ... but in vain, simply
> because I do not know how
> > to use them ..
> >
> > I have sent you the portion of my code, pls give me
> your suggestions.
> >
> > Rgds,
> > Ramesh.
> >
> >
> > --- On Tue, 4/11/08, Uthaiyashankar
> <[EMAIL PROTECTED]> wrote:
> >
> > > From: Uthaiyashankar <[EMAIL PROTECTED]>
> > > Subject: Re: Some quick Axis2C help required
> > > To: "Apache AXIS C User List"
> <axis-c-user@ws.apache.org>
> > > Date: Tuesday, 4 November, 2008, 1:09 PM
> > > Hi Ramesh,
> > >
> > > See the comments.
> > >
> > >
> > > > Sample xml request:
> > > > -------------------
> > > >
> > > > <operation>
> > > > <in1>1</in1>
> > > > <in2>2</in2>
> > > > </operation>
> > > >
> > > > My sample code :
> > > > ----------------
> > > >
> > > > if (node) { --- This is the entire xml
> > > > parent_node =3D
> axiom_node_get_first_element(node,
> > > env); --- Here, I though=
> > > > I will get operation as the first element,
> but I get
> > > <in1>1</in1> ...
> > > >
> > >
> > > You have to do
> "axiom_node_get_data_element" to
> > > get <operation> as the
> > > element. When you do
> axiom_node_get_first_element, it will
> > > return first
> > > child whose type is om element.
> > >
> > >
> > > > If this is wrong pls point out the exact
> function that
> > > I ought to be using.
> > > >
> > > > {
> > > > if (!parent_node)
> > > > { // throw error;
> > > > }
> > > > request_node =3D
> > > axiom_node_get_first_child(parent_node, env);
> > > > if (!request_node)
> > > > { // throw error;
> > > > }
> > > > if (request_node &&
> > > axiom_node_get_node_type(request_node, env)
> =3D=3D AXIO=
> > > > M_TEXT)
> > > > { // Get value of TEXT --- Here we get value
> > > "1"
> > > > }
> > > > }
> > > > sibling_node =3D
> > > axiom_node_get_next_sibling(parent_node, env);
> --- Here I =
> > > > get <in2>2</in2>, which is a
> sibling to
> > > <in1>1</in1>
> > > >
> > > > if (!sibling_node) { // throw error ; }
> > > > request_node =3D
> > > axiom_node_get_first_child(sibling_node, env);
> > > > if (!request_node)
> > > > { // throw error;
> > > > }
> > > > if (request_node &&
> > > axiom_node_get_node_type(request_node, env)
> =3D=3D AXIO=
> > > > M_TEXT)
> > > > { // Get value of TEXT --- Here we get value
> > > "2"
> > > > }=20
> > > > }
> > > >
> > > >
> > > > I am running into some issues
> > > >
> > >
> > >  First error is caused by
> axiom_node_free_detached_subtree,
> > > which I
> > > could not find in the code you have sent. Can you
> send the
> > > correct code
> > > which causes these errors?
> > >
> > > Regards,
> > > Shankar
> > >
> > > >
> > > > Below is some error which I get :
> > > > ---------------------------------
> > > >
> > > > Program received signal SIGSEGV,
> Segmentation fault.
> > > > [Switching to Thread -1208951888 (LWP
> 19071)]
> > > > axiom_node_free_detached_subtree
> (om_node=3D0x8927758,
> > > env=3D0x8920e60)
> > > > at om_node.c:105
> > > > 105 next_sibling =3D
> child_node->next_sibling;
> > > >
> > > > #0 axiom_node_free_detached_subtree
> > > (om_node=3D0x81d9758, env=3D0x81d2e60)
> > > > at om_node.c:105
> > > > #1 0x006005a2 in
> axiom_node_free_detached_subtree
> > > (om_node=3D0x81d96d0,=20
> > > > env=3D0x81d2e60) at om_node.c:106
> > > > #2 0x006005a2 in
> axiom_node_free_detached_subtree
> > > (om_node=3D0x81d9528,=20
> > > > env=3D0x81d2e60) at om_node.c:106
> > > > #3 0x006005a2 in
> axiom_node_free_detached_subtree
> > > (om_node=3D0x81d9478,=20
> > > > env=3D0x81d2e60) at om_node.c:106
> > > > #4 0x006005a2 in
> axiom_node_free_detached_subtree
> > > (om_node=3D0x81d9198,=20
> > > > env=3D0x81d2e60) at om_node.c:106
> > > > #5 0x0060026e in axiom_document_free
> > > (document=3D0x81d50b8, env=3D0x81d2e60=
> > > > )
> > > > at om_document.c:87
> > > > #6 0x00607b6e in axiom_stax_builder_free
> > > (om_builder=3D0x81d5010, env=3D0x8=
> > > > 1d2e60)
> > > > at om_stax_builder.c:897
> > > > #7 0x0060e7ad in axiom_soap_builder_free
> > > (soap_builder=3D0x81d50d8,=20
> > > > env=3D0x81d2e60) at soap_builder.c:188
> > > > #8 0x0060dd25 in axiom_soap_envelope_free
> > > (soap_envelope=3D0x81d9338,=20
> > > > env=3D0x81d2e60) at soap_envelope.c:178
> > > > #9 0x0806b2be in axis2_msg_ctx_free
> > > (msg_ctx=3D0x81d45f8, env=3D0x81d2e60)
> > > > at msg_ctx.c:410
> > > > #10 0x00c60b43 in
> axis2_http_worker_process_request
> > > (http_worker=3D0x81d0d3=
> > > > 8,=20
> > > > env=3D0x81d2e60, svr_conn=3D0x81d2e80,
> > > simple_request=3D0x81d2f48)
> > > > at http_worker.c:1952
> > > >
> > > > Program received signal SIGSEGV,
> Segmentation fault.
> > > > [Switching to Thread -1208378448 (LWP
> 18971)]
> > > > axiom_node_create (env=3D0x20202020) at
> om_node.c:75
> > > > 75 node =3D (axiom_node_t *)
> > > AXIS2_MALLOC(env->allocator,
> sizeof(axiom_node=
> > > > _t));
> > > >
> > > > #0 axiom_node_create (env=3D0x20202020) at
> > > om_node.c:75
> > > > #1 0x00f250fa in axiom_element_create
> > > (env=3D0x20202020, parent=3D0x0,=20
> > > > localname=3D0x4e9f8c "outparam0",
> ns=3D0x0,
> > > node=3D0xb7f98f30) at om_elemen=
> > > > t.c:78
> > > > #2 0x004e9a0f in build_res_text_response ()
> > > > from
> ..//services/ws_test_demo/libws_test_demo.so
> > > > #3 0x004e99ac in
> axis2_skel_ws_test_demo_test_demo ()
> > > > from
> ..//services/ws_test_demo/libws_test_demo.so
> > > > #4 0x20202020 in ?? ()
> > > > #5 0x20202020 in ?? ()
> > > > #6 0x20202020 in ?? ()
> > > > #7 0xb7f99000 in ?? ()
> > > > #8 0x004e9b62 in
> axis2_svc_skel_ws_test_demo_invoke ()
> > > > from
> ..//services/ws_test_demo/libws_test_demo.so
> > > >
> > > >
> > > > Pls let me know, if I am missing something
> ...
> > > >
> > > > Also, pls let me know if you need more info.
> > > > I need some help on an urgent basis.
> > > >
> > > > Rgds,
> > > > Ramesh
> > > >
> > > >
> > > >       Add more friends to your messenger and
> enjoy! Go
> > > to http://messenger.yahoo.com/invite/
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > S.Uthaiyashankar
> > > Software Architect
> > > WSO2 Inc.
> > > http://wso2.com/ - "The Open Source SOA
> Company"
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> >
> >
> >       Share files, take polls, and make new friends -
> all under one roof.
> > Go to http://in.promos.yahoo.com/groups/
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
> 
> 
> -- 
> Software Engineer, WSO2 Inc
> http://wso2.org
> Web Services with Axis2/C http://wsaxc.blospot.com


      Get rid of Add-Ons in your email ID. Get [EMAIL PROTECTED] Sign up now! 
http://in.promos.yahoo.com/address


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to