PDA

View Full Version : چطور از سایت برنامه نویس خروجی rss بگیریم؟



barbodsoft.com
سه شنبه 27 اردیبهشت 1390, 19:53 عصر
سلام دوستان
نمی دونم این مطلب اصلا امکان پذیر هست یا نه. می شه راهنمایی کنید.

arta.nasiri
سه شنبه 27 اردیبهشت 1390, 21:33 عصر
سلام

خروجی Rss سایت رو میتونید از این (http://barnamenevis.org/external.php)لینک دریافت کنید.
برای کار باهاشم میتونید از XmlReader استفاده کنید.

barbodsoft.com
پنج شنبه 29 اردیبهشت 1390, 13:59 عصر
می شه بیشتر توضیح بدید.
من خیلی برنامه نویسی وب کار نکردم. بیشتر app کار کردم.

اگه می شه یک نمونه کوچولو برام بزاری ممنون می شم.

arta.nasiri
جمعه 30 اردیبهشت 1390, 03:27 صبح
سلام

با این (http://www.java2s.com/Code/ASP/XML/ReadinganXMLFileandattributesusingXmlReader.htm)م یتونی کار کنی

barbodsoft.com
جمعه 30 اردیبهشت 1390, 11:24 صبح
سلام

با این (http://www.java2s.com/Code/ASP/XML/ReadinganXMLFileandattributesusingXmlReader.htm)م یتونی کار کنی
لینک بالا باز نمی شه.

arta.nasiri
جمعه 30 اردیبهشت 1390, 13:38 عصر
سلام

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
//string xmlFilePath = @"C:\Data\Employees.xml";
string xmlFilePath = MapPath("Employees.xml");
try
{
using (XmlReader reader = XmlReader.Create(xmlFilePath))
{
string result;
while (reader.Read())
{
//Process only the elements
if (reader.NodeType == XmlNodeType.Element)
{
result = "";
for (int count = 1; count <= reader.Depth; count++)
{
result += "===";
}
result += "=> " + reader.Name;
lblResult.Text += result;
// check if the element has any attributes
if (reader.HasAttributes)
{
lblResult.Text += " (";
for (int count = 0; count < reader.AttributeCount; count++)
{
//Read the current attribute
reader.MoveToAttribute(count);
lblResult.Text += reader.Name;
}
lblResult.Text += ")";
//Instruct the parser to go back the element
reader.MoveToElement();
}
lblResult.Text += "<br/>";
}
}
}
}
catch (Exception ex)
{
lblResult.Text = "An Exception occurred: " + ex.Message;
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Reading an XML File and attributes using XmlReader</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label id="lblResult" runat="server" />
</div>
</form>
</body>
</html>

<%--
<?xml version='1.0'?>
<employees>
<employee id="1">
<name>
<firstName>Nancy</firstName>
<lastName>Lee</lastName>
</name>
<city>Seattle</city>
<state>WA</state>
<zipCode>98122</zipCode>
</employee>
<employee id="2">
<name>
<firstName>Jason</firstName>
<lastName>Wang</lastName>
</name>
<city>Vancouver</city>
<state>WA</state>
<zipCode>98123</zipCode>
</employee>
</employees>

--%>

barbodsoft.com
جمعه 30 اردیبهشت 1390, 16:17 عصر
تو این خط


string xmlFilePath = MapPath("Employees.xml");


این خطا رو می ده
'http://glimche.persianblog.com/rss.xml' is not a valid virtual path

هر آدرس دیگری هم بهش می دم بازم همین خطا رو داره

arta.nasiri
جمعه 30 اردیبهشت 1390, 16:26 عصر
اینجوری باید باشه
string xmlFilePath = "http://glimche.persianblog.com/rss.xml";

barbodsoft.com
جمعه 30 اردیبهشت 1390, 17:12 عصر
اینجوری باید باشه
string xmlFilePath = "http://glimche.persianblog.com/rss.xml";

به این شکل اصلاح کردم


string xmlFilePath = "http://p30world.com/index.xml";


ولی صفحه رو به این شکل نشون می ده

=> feed (xmlns)====> title====> link (reltypehref)====> link (reltypehref)====> id====> updated====> generator (uri)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)=======> category (termlabelscheme)=======> category (termlabelscheme)=======> category (termlabelscheme)=======> category (termlabelscheme)=======> category (termlabelscheme)=======> category (termlabelscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)====> entry=======> title=======> link (reltypehref)=======> id=======> published=======> updated=======> author==========> name=======> category (termscheme)=======> category (termscheme)

barbodsoft.com
جمعه 30 اردیبهشت 1390, 17:18 عصر
یک لینک تو msdn پیدا کردم . من خودم ازش سر در نیاوردم تو سیستم من هم درست کار نکرد. اگه می شه شما بررسی بفرمایید
http://archive.msdn.microsoft.com/CreateRSSFeedVBNet

arta.nasiri
جمعه 30 اردیبهشت 1390, 18:03 عصر
سلام

یک روش ساده

string xmlFilePath = "http://barnamenevis.org/external.php";
using (XmlReader reader = XmlReader.Create(xmlFilePath))
{
DataSet ds = new DataSet();
while (reader.Read())
{
ds.ReadXml(reader, XmlReadMode.Auto);
}
GridView1.DataSource = ds.Tables[3];
GridView1.DataBind();
}

با تغییر ایندکس ds.Tables میتونید اطلاعاتی مختلفی رو از rss بگیرید.
البته یک GridView هم به صفحه اضافه کنید.

barbodsoft.com
جمعه 30 اردیبهشت 1390, 18:27 عصر
دوست عزیز شرمنده اینهمه وقت شما رو می گیرم. بازم نشد. اگه می شه به همرا یک پروژه قرار بدید.

به این شکل استفاده کردم




<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<script runat ="server" >
string xmlFilePath = "http://barnamenevis.org/external.php";
using (XmlReader reader = XmlReader.Create(xmlFilePath))
{
DataSet ds = new DataSet();
while (reader.Read())
{
ds.ReadXml(reader, XmlReadMode.Auto);
}
GridView1.DataSource = ds.Tables[3];
GridView1.DataBind();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>



اشکال از کجاست که اجرا نمی شه؟

arta.nasiri
جمعه 30 اردیبهشت 1390, 18:58 عصر
من پیشفرض لینک rss برنامه نویس رو گذاشتم ولی مثل اینکه مشکل داره!
شما واسه تست میتونید از لینک های دیگه استفاده استفاده کنید

barbodsoft.com
جمعه 30 اردیبهشت 1390, 19:18 عصر
نه بخاطر اون نیست. من هر آدرسی دادم بازم همین خطا رو می ده. می تونی خودت آزمایش کنی.

arta.nasiri
جمعه 30 اردیبهشت 1390, 19:46 عصر
سلام

ببخشید این یادم رفته بود
using System.Xml;

اگه بازم خطا داد متن خطا رو اینجا بذارید.

barbodsoft.com
جمعه 30 اردیبهشت 1390, 21:03 عصر
شد ولی ... بهم ریخته هست.

arta.nasiri
جمعه 30 اردیبهشت 1390, 21:53 عصر
چجوری نشون میده ؟ اگه میشه اینجا کپی کنید

barbodsoft.com
شنبه 31 اردیبهشت 1390, 02:16 صبح
فونت و نوشتش درسته ولی اون چیزی که از یک rss انتظار داریم نیست. چطور باید تعیین کنیم که هر کدوم کجا نمایش داده بشه؟

arta.nasiri
شنبه 31 اردیبهشت 1390, 03:01 صبح
سلام

تو این خط

GridView1.DataSource = ds.Tables[3];

عدد 3 که ایندکس هست رو تغییر بدین.