Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET, XML and Web Services

Status
Not open for further replies.

SonJ

Programmer
Oct 24, 2002
166
GB
Hi,

I need some help. I have a web service from which I request information and it is returned in the following format.

Code:
<SearchResult NumberOfHits="1" xmlns="PeopleSearchers">
    <Entry>
        <FirstName>FirstName</FirstName>
        <LastName>LastName</LastName>
        <Department>Department</Department>
        <Email>Email</Email>
    </Entry>
</SearchResult>

What I need to do is assign each of these values to a textbox. How can I access each one of these values using and assign them to a textbox.

Thanks in advance
SonJ
 
How is your data returned - are you seeing it as an xml document, a string or a soap message?

however it is recieved, eventually you will need to process it, best method I have found is to use somethng along the lines of

(partly pseudocode as I cant remember all the property names)

Code:
XmlElement myElement = <the data>
foreach (XmlNode n in myElement)
{
  if (n.Name == "Entry")
  {
    foreach (XmlNode sn in n)
    {
        .. parse the Entry record and Strip out the Data
    }
  }
}

Sorry its not a complete working fragment, but its all I can recall off the top of my head!

If anyone has a better method I'd be keen to know as well
 
Thanks for the response Kalisto. I have been trying to replicate the pseudocode into my application and all it seems to return is 8 whitespace characters. Can someone explain why this is the case. Incidentally, I am using VB.NET.

Regards,
SonJ
 
>> I have a web service from which I request information and it is returned in the following format

how exactly are u calling it?
try this:

TheXmlDoc=new XmlDocument()
TheXmlDoc.load(SOURCE)
Dim root As XmlNode = TheXmlDoc.FirstChild
if root.HasChildNodes then
FirstName.text=root.ChildNodes(0).InnerText
LastName.text=root.ChildNodes(1).InnerText

'etc

end if


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top