Click here to Skip to main content
15,392,858 members

Comments by hm9 (Top 18 by date)

hm9 25-Dec-19 11:39am View
   
The issue is the files could be different format. I am trying to find a way to append the results of both datasources together into one and then bind the repeater to it something like below but need something to work:

datasource3 = datasource1 + datasource2
rpMyRepeater.Datasource = datasource3
hm9 24-Dec-19 15:48pm View
   
The issue I have isnt with getting the data. The data can be viewed but it cant be bound to the repeater properly, It always binds the last one so it overwrites the first one. So in the code below, both datasources 1 and 2 show data but not simultaneously. if I swap the order, it always shows the second one, so it is the binding that is the issue. Need to find a way to add both datasources 1 and 2 to another item and then bind that item ?

Dim dataSource1 As IEnumerable
Dim dataSource2 As IEnumerable

rpMyRepeater.Datasource = datasource1
rpMyRepeater.Datasource = datasource2
rpMyRepeater.Databind()
hm9 6-Dec-19 17:19pm View
   
Ok I tried this method by loading 3 APIs in this way:


Dim doc As New XmlDocument()
dim doc1 = ("AP1")
dim doc2 = ("AP2")
dim doc3 = ("AP3")


doc.Load(doc1)
doc.Load(doc2)
doc.Load(doc3)

But this always load the last one API3 and ignores the first 2. Is there a way to get to load all three instead of only the third one?
hm9 4-Dec-19 10:49am View
   
Yes the results should be the same. So I just want to know if another API like this one below can be added so I can query both instead of just one

http://api.test.com/1.0/products.xml;q=paris?token=SAD345A8718524374ZXZXCVMSHWEU8"
hm9 3-Dec-19 15:04pm View
   
The above example is how I m interacting with one API. Is there a way to add another API to the above code?
hm9 7-Oct-19 15:12pm View
   
below is the code just give you context. The url is correcct but It doesnt appear to be getting the values from the xml but I am sure it worked before...

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="true" %>

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Web.UI.WebControls" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Net.HttpWebResponse" %>
<%@ import Namespace="System.Linq" %>
<%@ import Namespace="System.Configuration"%>
<%@ Import Namespace="System.Xml.XLinq"%>
<%@ Import Namespace="System.Xml.Linq"%>
<%@ Import Namespace="System.Xml.XPath"%>


Sub Button_Click( s As Object, e As EventArgs )
if IsValid then

response.redirect("redirecting2.aspx")
end if
end sub








sub Page_Load
if Not Page.IsPostBack then




Dim doc As New XmlDocument()
doc.Load("https://api.tradedoubler.com/1.0/products.xml;q=hotels?token=A87185243749DAC9685310F6FEEB7F9038DD7F88")
Dim nsManager As New XmlNamespaceManager(doc.NameTable)
nsManager.AddNamespace("ns1", "urn:com:tradedoubler:pf:model:xml:output")
nsManager.AddNamespace("ns2", "urn:com:tradedoubler:pf:model:xml:common")
Dim nodes As XmlNodeList = doc.SelectNodes("//ns1:products/ns1:product", nsManager)

Dim dataSource As IEnumerable
dataSource = From node As XmlNode in nodes
Select Name = node.SelectSingleNode("ns2:name", nsManager).InnerText, _
Description = node.SelectSingleNode("ns2:description", nsManager).InnerText, _
Image = node.SelectSingleNode("ns2:productImage", nsManager).InnerText, _
Price = node.SelectSingleNode("ns1:offers/ns1:offer/ns1:priceHistory/ns2:price", nsManager).InnerText, _
ProductUrl = node.SelectSingleNode("ns1:offers/ns1:offer/ns2:productUrl", nsManager).InnerText, _
Logo = node.SelectSingleNode("ns1:offers/ns1:offer/ns2:programLogo", nsManager).InnerText
rpMyRepeater.DataSource = dataSource
rpMyRepeater.DataBind()
doc.RemoveAll()
Dispose()

End if
end sub


<asp:repeater id="rpMyRepeater" onitemcommand="Button_Click" runat="Server">

<headertemplate>



<itemtemplate>








<footertemplate>


Image

Name

Description

Price

Provider

Link

<asp:image runat="server" width="100" height="100"
="" imageurl="<%# Eval("Image") %>">
<%# Eval("Name") %>



<%#Eval("Description").ToString().PadLeft(140).Substring(0,140).TrimEnd()%>....

£<%# Eval("Price") %> <asp:image runat="server" width="130" onclick="Button_Click" imageurl="<%# Eval("logo")%>">
" target="_blank" ">Go To Website
hm9 7-Oct-19 14:02pm View
   
Everything works in the code apart from the url i posted. It doesnt like the url for some reason even though it works on the browser!
hm9 7-Sep-15 11:13am View
   
The xml file is in this link:

http://api.tradedoubler.com/1.0/products.xml?token=96CC0E0A10851500F10431D64EC5585BFC8597DF"
hm9 4-Sep-15 16:08pm View
   
Hi Richard, Just realised I also want to retrieve the values of price, productUrl but these are under offers/offer namespace. how do I achieve this? I tried adding it to the XmlNodeList but then i will miss the other elements directly under product. Thanks
hm9 25-Aug-15 11:50am View
   
You are right it wasn't using 3.5. Changed it and it worked. Thanks again
hm9 25-Aug-15 10:27am View
   
Ok I tried that but still the same error. One thing may be is the ns1 namespace. This isn't on the xml ? but as you stated, it works on your environment
hm9 25-Aug-15 9:55am View
   
3.5 I am using it on a local server. Does it work on yours?
hm9 25-Aug-15 9:33am View
   
Its just I get the error: Name 'From' is not declared.
hm9 25-Aug-15 9:21am View
   
Thanks Richard. I assume there is a typo in the line below?:

dataSource = From node As XmlNode in nodes
hm9 25-Aug-15 7:48am View
   
Would it be possible to adapt my code to work with xmlnamespaceManager. I don't know c# only VB.net.
hm9 24-Aug-15 16:52pm View
   
Its in the URL link

http://api.tradedoubler.com/1.0/products.xml?token=96CC0E0A10851500F10431D64EC5585BFC8597DF
hm9 24-Aug-15 16:16pm View
   
Ok I corrected the syntax now. Regarding the xml, below is an extract of the xml file, I am trying to access. The nodes I am trying to get to is products/product and the value of ns2:description is what i want to output. but it doesnt show anything on the page. I did change the 'description' for 'ns2:description' but it didnt make a difference

<result xmlns="urn:com:trade:pf:model:xml:output" xmlns:ns2="urn:com:trade:pf:model:xml:common" version="3.0">
<productHeader>
<totalhits>591727
</productHeader>
<products>
<product language="en">
<ns2:name>La Roche Posay
<ns2:description>
La Roche Posay - Effaclar H etc
hm9 24-Aug-15 15:44pm View
   
Ok thanks I corrected the code as you suggested and the error is cleared but it is complaining about this line:

<![CDATA[<%# ((System.Xml.XmlNode)Container.DataItem).Attributes["description"].Value %>]]>

The error:
'XmlNode' is a type in 'Xml' and cannot be used as an expression.

any ideas? is it syntax issue?