0

I posted a while ago a question about how to read values from XML, and there was a perfect answer, it was so neat and so simple yet I can not understand it and apply it on some other XML!!!

can some one help me with this one? I need to read the "id" or the "ChangeKey"

<soap:Envelope>
<soap:Header>
 <t:ServerVersionInfo MajorVersion="8" MinorVersion="2" MajorBuildNumber="217" MinorBuildNumber="0"/>
 </soap:Header>
<soap:Body>
<m:CreateItemResponse>
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
 <m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
 <t:ItemId Id="erwrweff3424dfw23r2fwfwsfwsfg34fwdf2" ChangeKey="sdfwwerw4224rw"/>
 </t:CalendarItem>
 </m:Items>
 </m:CreateItemResponseMessage>
 </m:ResponseMessages>
 </m:CreateItemResponse>
 </soap:Body>
 </soap:Envelope>

I really don't feel good because I'm not able to understanding it!

Community
  • 1
  • 1
Data-Base
  • 8,418
  • 36
  • 74
  • 98

1 Answers1

1

Do the same thing as in the answer you referenced, but change the XPath expression (second argument to XMLTYPE) from

'//SOAProxyResult'

to e.g.

'//t:ItemId/@Id'

or

'//t:ItemId/@ChangeKey'

The third argument will need to declare the t namespace prefix:

'xmlns:t="foobarbaz"'

and of course your input XML will need to declare that namespace prefix too.

Community
  • 1
  • 1
LarsH
  • 27,481
  • 8
  • 94
  • 152
  • Thanks allot, but that's how I get the XML from the server! without namespace! – Data-Base Mar 22 '11 at 15:19
  • and I have to add xmlns:t="foobarbaz" xmlns:soap="foobarbaz" xmlns:m="foobarbaz" so it will work, hmmmmmmmm – Data-Base Mar 22 '11 at 15:21
  • No worries I solved it, I created a function that delete :SOAP, :t, :m from the xml code and then run it with out namespaces, worked perfectly, thanks allot for the help – Data-Base Mar 22 '11 at 15:29
  • Bleah, you're getting not-namespace-wellformed XML from the server? I would tell whoever's responsible for that service that it's outputting garbage. – LarsH Mar 24 '11 at 12:46