English 中文(简体)
Ebay RSS(XML:RSS模块)
原标题:Reading custom values in Ebay RSS feed (XML::RSS module)

我花了很长的时间试图说明这一点。 使用XML的Im: RSS和Perl读/ parse an Ebay RSS饲料。 在<代码><item></item> area, I see these submissions:

<rx:BuyItNowPrice xmlns:rx="urn:ebay:apis:eBLBaseComponents">1395</rx:BuyItNowPrice>
<rx:CurrentPrice xmlns:rx="urn:ebay:apis:eBLBaseComponents">1255</rx:CurrentPrice>

然而,我无法说明如何在 lo期间 details弄细节。 我写了一封信,以 gr笑他们:

@current_price = $item  =~ m/<rx:CurrentPrice.*>(d+)</rx:CurrentPrice>/g;

如果你将上述现行课程列入独立的插图,但书本通过RSS读书时不行。

我可以忽略我想要的多数信息,即项目和特制描述区(标本、拍卖结束时间、BIN价格、th形图像等),但是,如果我不能用人工处理所有这种信息,我会感到迷惑不解。

如何从RSS的饲料中放牧习惯田地(没有书写的reg,无法整条饲料/单元)?

这里的法典Im涉及:

$my_limit = 0;
use LWP::Simple;
use XML::RSS;

$rss = XML::RSS->new();
$data = get( $mylink );
$rss->parse( $data );

$channel = $rss->{channel};

$NumItems = 0;
foreach  $item (@{$rss->{ items }}) {
if($NumItems > $my_limit){
last;
}

@current_price = $item =~ m/<rx:CurrentPrice.*>(d+)</rx:CurrentPrice>/g;

print "$current_price[0]";

}
问题回答

如果您有rs/xml文件,并想要获得具体数据,可使用XPATH:

Perl CPAN XPATH

XPath Introduction/a>

RSS提供的“从事t 工作”是怎样的? 你们是否意味着在什么时候应当配对? 或者说,在哪些地方应当有好几套配对?

在我跳出你经常表达的一件事是,你使用<条码>。 即<代码>项目 声明

<rx:BuyItNowPrice xmlns:rx="urn:...nts">1395</rx:BuyItNowPrice>
<rx:CurrentPrice xmlns:rx="urn:...nts">1255</rx:CurrentPrice>
<rx:BuyItNowPrice xmlns:rx="urn:...nts">1395</rx:BuyItNowPrice>
<rx:SomeMoreStuff xmlns:rx="urn:...nts">zzz</rx:BuyItNowPrice>
<rx:CurrentPrice xmlns:rx="urn:...nts">1255</rx:CurrentPrice>

然后,您的定期表述(<rx:CurrentPrice.*>)的第一部分将按第2、第3和第4行及第5行的第一部分(>)核对所有内容。 相反,你可能希望使用常规表述<>1。

m/<rx:CurrentPrice[^>]*>(d+)</rx:CurrentPrice>/

仅与封闭式<代码></rx:CurrentPrice> tag在开放式<rx:CurrentPrice> tag。

<>1> 另一明显答案是,你真的不想使用定期表达,与定制的教职单元相比,经常表达是贬低XML的工具,而你处理的所有特殊案件最终都会使你不知会一再殴打你的主管。 例如,见Salgar的答复。





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签