Hi Charles,

Thanks for your reply! However, I'm still facing some problems since this did 
not give me what I need.. More comments inline...


>===== Original Message From "Karpinski, Charles" <[EMAIL PROTECTED]> 
=====
>Returns the value of the first name in the first occurrence of the name
>element.  Replace the 1 with a 2 to get the second persons first name:
>/doc/name[1]/@first

-- For the xml that I'll be using I don't know how many name elements will be 
present (or at least, I don't know how to get this information using Xalan). 
So, I can't index the names

>or this to get a list of all the first names:
>/doc/name/@first

This didn't work too well :(... These are my results:


mySerializeNodeSet SerializeNodeSet/foo.xml / /doc/name/@first

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.

Warning: An attribute or namespace node was selected.  Attribute and namespace 
nodes cannot be serialized.




>To get the first foo element from each, try this
>
>/doc/name/foo[1]

>Hope that answered your questions.
>
>Charles


Any advice/clues as to how I could advance, both in relation to my original 
questions (below) as well as my confusion (above)! Please help!

Thanks,
Kaushal


>-----Original Message-----
>From: Kaushal Sanghavi [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, July 16, 2003 10:00 PM
>To: xalan-c-users
>Subject: getting a set of attribute values from xml using c
>
>
>This is what I'm trying:
>
>I'm just toying with the SerializeNodeSet sample code, and using the foo.xml
>as data. I've changed foo.xml to look like this:
>
><?xml version="1.0"?>
><doc>
>  <name first="David" last="Marston">Mr. Marston
>   <foo> 123  </foo>
>    <foo> 358  </foo>
>     <foo> 526  </foo>
>  </name>
>  <name first="David" last="Bertoni">Mr. Bertoni
>   <foo> 1238  </foo>
>    <foo> 3585  </foo>
>     <foo> 5266  </foo>
>     <foo> sjk </foo>
>  </name>
>
>  <name first="Donald" last="Leslie">Mr. Leslie</name>
>  <name first="Emily" last="Farmer">Ms. Farmer</name>
>  <name first="Myriam" last="Midy">Ms. Midy</name>
>  <name first="Paul" last="Dick">Mr. Dick</name>
>  <name first="Scott" last="Boag">Mr. Boag</name>
>  <name first="Shane" last="Curcuru">Mr. Curcuru</name>
>  <name first="Joseph" last="Kesselman">Mr. Kesselman</name>
>  <name first="Stephen" last="Auriemma">Mr. Auriemma</name>
></doc>
>
>Two questions:
>1. I'm trying to get only the value enclosed in the foo element.
>(for eg., output should be:  "123, 358, 526," in the above). Instead, what 
I'm getting is the following:
>bash-2.03$ SerializeNodeSet SerializeNodeSet/foo.xml / //foo
><foo> 123  </foo><foo> 358  </foo><foo> 526  </foo><foo> 1238  </foo><foo>
>3585  </foo><foo> 5266  </foo><foo> sjk </foo>
> How can I get rid of the extra <foo> </foo> around each value ?



>2. I'm trying to get a list of only the first names, i.e. the value stored
>in
>the attribute "name/@first" . How can I do that?
I get the error - "Warning: An attribute or namespace node was selected.  
Attribute and namespace nodes cannot be serialized." if I ever try to get the 
value stored in an attribute of an element.


> - Also, how do I insert a \n or a space, or some de-limiting character
>between the results, so I don't get everything as one continous string, as
>above?
>
>I'm hoping these will be easy for all the xalan gurus out there! :)
>
>Thanks,
>Kaushal

Reply via email to