Scudboy
asked on
Visual Basic XML Question
Hello Experts - venturing into dangerous territory (for me at least) today.
I'm experimenting with using a web service to go through an XML data set and return a value based on a supplied parameter. In this case, match a URL to a particular Project
Here's an example of the XML file:
Now here - (and please be gentle folks - not a programmer but I'm trying to learn) - is what I've attempted to code to return the value.
Am I approaching this remotely close to how I should? I don't get anything returned from the function except the top of the XML file -
I'm experimenting with using a web service to go through an XML data set and return a value based on a supplied parameter. In this case, match a URL to a particular Project
Here's an example of the XML file:
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/">
<Result>
<NumberOfRecords>9</NumberOfRecords>
<TotalNumberOfRecords>9</TotalNumberOfRecords>
</Result>
<List>
<Survey>
<Id>18746</Id>
<Name>General Satisfaction</Name>
<SurveyTemplate>
<Id>95</Id>
<Name>General Satisfaction</Name>
</SurveyTemplate>
<Project>
<Id>13542</Id>
<Number>Test123123</Number>
<Name>CompanyName</Name>
</Project>
<StartDate>2012-09-09 00:00:00</StartDate>
<CloseDate>2012-09-23 00:00:00</CloseDate>
<ReminderDate>2012-09-20 00:00:00</ReminderDate>
<ReminderSent>False</ReminderSent>
<AllowInvitingAdditionalPeople>False</AllowInvitingAdditionalPeople>
<Sender>
<Email>email@domain.com</Email>
<FirstName>Mark</FirstName>
<LastName>Fancy</LastName>
</Sender>
<Recipients>
<Recipient>
<Id>9be15d9b-f210-4fb8-94d7-be21eaf49c18</Id>
<Email>email@domain.com</Email>
<FirstName>Mark</FirstName>
<LastName>Fancy</LastName>
<OriginalSender>email@domain.com</OriginalSender>
<Status>Not Started</Status>
<SentOn>2012-09-09 09:12:31</SentOn>
<LastActivityDate/>
<FinishedOn/>
<IsDismissed>False</IsDismissed>
<IsForwarded>False</IsForwarded>
<LinkToSurvey>http://www.CompanyName.com/v20/surveys/take.aspx?ident=9be15d9b-f210-4fb8-94d7-be21eaf49c18</LinkToSurvey>
<EmailSubject>CompanyName</EmailSubject>
<Responses/>
</Recipient>
</Recipients>
<Questions>
<Question>
<Title>How well does our process provide work of appropriate quality?</Title>
<Category>Quality</Category>
<IsCustom>False</IsCustom>
<Order>1</Order>
</Question>
<Question>
<Title>How well does our process help you manage your project budget?</Title>
<Category>Budget</Category>
<IsCustom>False</IsCustom>
<Order>2</Order>
</Question>
</Questions>
<Tags/>
<SentFromGenericEmail>False</SentFromGenericEmail>
<IncludeNPS>False</IncludeNPS>
<InvitationText>Our goal is to constantly provide the highest level of service possible. We recently received feedback from you indicating an opportunity exists for us to improve for you. Now that we’ve had some time to address the issues, we’d like to check in on how our modified approach is working for you.<br/><br/>Unlike a generic survey, this request is specific to you, your project, and the team of professionals currently helping meet your project objectives. Your response will immediately be delivered to the right people, assuring we turn your feedback into better project outcomes for you.<br/><br/>If you wish to discuss this process or provide feedback personally, please contact us so we may address your concerns.<br/><br/>Responding to this electronic feedback request should take fewer than 2-3 minutes and is one of the easiest ways you can improve how we help you.</InvitationText>
<ThankYouMessage>Thank you for your feedback!</ThankYouMessage>
</Survey>
<Survey>
<Id>18462</Id>
<Name>One Page Client Satisfaction</Name>
<SurveyTemplate>
<Id>365</Id>
<Name>One Page Client Satisfaction</Name>
</SurveyTemplate>
<Project>
<Id>14133</Id>
<Number>0000020.03</Number>
<Name>Gilbert Elementary School</Name>
</Project>
<StartDate>2012-08-29 00:00:00</StartDate>
<CloseDate>2012-10-15 00:00:00</CloseDate>
<ReminderDate>2000-01-01 00:00:00</ReminderDate>
<ReminderSent>False</ReminderSent>
<AllowInvitingAdditionalPeople>True</AllowInvitingAdditionalPeople>
<Sender>
<Email>feedback@fullsailpartners.com</Email>
<FirstName>Client</FirstName>
<LastName>Feedback</LastName>
</Sender>
<Recipients>
<Recipient>
<Id>c1a5e7a5-7b16-4e34-9479-3e3ee60add35</Id>
<Email>email@domain.com</Email>
<FirstName>Mark</FirstName>
<LastName>Fancy</LastName>
<OriginalSender>email@domain.com</OriginalSender>
<Status>Not Started</Status>
<SentOn>2012-08-29 11:04:26</SentOn>
<LastActivityDate/>
<FinishedOn/>
<IsDismissed>False</IsDismissed>
<IsForwarded>False</IsForwarded>
<LinkToSurvey>http://www.URLHERE.com/v20/surveys/take.aspx?ident=c1a5e7a5-7b16-4e34-9479-3e3ee60add35</LinkToSurvey>
<EmailSubject>Tell Us How We Did</EmailSubject>
<Responses/>
</Recipient>
</Recipients>
<Questions>
<Question>
<Title>Please evaluate how well the services provided met your expectations in the following areas:</Title>
<Category>Expectations</Category>
<IsCustom>False</IsCustom>
<Order>1</Order>
</Question>
<Question>
<Title/>
<Category>Helpfulness</Category>
<IsCustom>False</IsCustom>
<Order>2</Order>
</Question>
<Question>
<Title/>
<Category>Responsiveness</Category>
<IsCustom>False</IsCustom>
<Order>3</Order>
</Question>
<Question>
<Title/>
<Category>Quality</Category>
<IsCustom>False</IsCustom>
<Order>4</Order>
</Question>
<Question>
<Title/>
<Category>Accuracy</Category>
<IsCustom>False</IsCustom>
<Order>5</Order>
</Question>
<Question>
<Title/>
<Category>Schedule</Category>
<IsCustom>False</IsCustom>
<Order>6</Order>
</Question>
<Question>
<Title/>
<Category>Budget</Category>
<IsCustom>False</IsCustom>
<Order>7</Order>
</Question>
<Question>
<Title/>
<Category>Scope and Fees</Category>
<IsCustom>False</IsCustom>
<Order>8</Order>
</Question>
</Questions>
<Tags/>
<SentFromGenericEmail>False</SentFromGenericEmail>
<IncludeNPS>False</IncludeNPS>
<InvitationText>Hello, please help us out!</InvitationText>
<ThankYouMessage>Thank you for your feedback!</ThankYouMessage>
</Survey>
</List>
</Response>
Now here - (and please be gentle folks - not a programmer but I'm trying to learn) - is what I've attempted to code to return the value.
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CFTGetSurveys2
Inherits System.Web.Services.WebService
Dim Link As String
<WebMethod()> _
Public Function HelloWorld(ByVal ProjectNumber As String) As String
Dim EntireXML As String = "https://localhosthost/api/surveyssent?UserName=feedback@company.com&Password=company&output=xml"
Dim doc = XDocument.Load(EntireXML)
Dim query = From cust In doc...<List> _
Where cust.<Survey>.<Project>.<Number>.Value = ProjectNumber And cust.<Survey>.<SurveyTemplate>.<Id>.Value = "95" _
Select Link = cust.<Survey>.<Recipients>.<Recipient>.<LinkToSurvey>.Value
Return Link
End Function
End Class
Am I approaching this remotely close to how I should? I don't get anything returned from the function except the top of the XML file -
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No response -
e.g.
Open in new window