繁体   English   中英

如何找到单个用户发布的所有“Parentid”问题?

[英]How to find all "Parentid" quetsions that a single users posts are connected to?

在其中一个 stackexchange 站点(比如这个)的 xml 数据转储中,我想找到特定用户写的所有答案以及他们回答的所有问题

我通过从不同人的大量问题/答案中搜索“OwnerUserID =“x”找到了他们所有的答案......但现在我想找到这个用户已经回答的所有问题 - 并且每个答案(有“PostTypeID=”2”——问题有“1”)也有一个标签“ParentID”

我正在使用记事本++

这是几行示例,我将正文标签的内容更改为“答案/问题”,将标题更改为“标题”...(注意最后一行(第 18 行)是第一行的答案(第 13 行)因为它的 parentid 是 13:

<row Id="13" PostTypeId="1" CreationDate="2014-06-18T09:38:43.457" Score="4" ViewCount="142" Body="&lt;p&gt;one question;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="254" LastEditDate="2017-06-12T15:04:30.633" LastActivityDate="2017-06-12T15:04:30.633" Title="title" Tags="&lt;discussion&gt;&lt;faq&gt;&lt;allowed-questions&gt;&lt;tags&gt;&lt;traditions&gt;" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
<row Id="14" PostTypeId="2" ParentId="1" CreationDate="2014-06-18T10:53:37.200" Score="-3" Body="&lt;p&gt;another question.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="106" LastActivityDate="2014-06-18T10:53:37.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
<row Id="15" PostTypeId="2" ParentId="7" CreationDate="2014-06-18T13:00:53.940" Score="3" Body="&lt;p&gt;an answer/p&gt;&#xA;" OwnerUserId="18" LastActivityDate="2014-06-18T13:00:53.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />    
<row Id="16" PostTypeId="2" ParentId="11" CreationDate="2014-06-18T13:07:20.333" Score="1" Body="&lt;p&gt;I answer.&lt;/p&gt;&#xA;" OwnerUserId="40" LastActivityDate="2014-06-18T13:07:20.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" /> 
<row Id="17" PostTypeId="1" CreationDate="2014-06-18T13:31:36.430" Score="4" ViewCount="159" Body="&lt;p&gt;answer&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="254" LastEditDate="2014-10-10T19:58:18.847" LastActivityDate="2014-10-10T19:58:18.847" Title="title" Tags="&lt;discussion&gt;&lt;site-promotion&gt;&lt;beta&gt;" AnswerCount="4" CommentCount="2" FavoriteCount="1" ContentLicense="CC BY-SA 3.0" />
<row Id="18" PostTypeId="2" ParentId="13" CreationDate="2014-06-18T13:51:11.940" Score="4" Body="&lt;p&gt;answer.&lt;/p&gt;&#xA;" OwnerUserId="18" LastActivityDate="2014-06-18T13:51:11.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
<row Id="19" PostTypeId="2" ParentId="13" CreationDate="2014-06-18T14:06:56.237" Score="13" Body="&lt;answer. &lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:53.840" LastActivityDate="2014-06-18T14:39:08.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />

您可以使用正则表达式在数据转储中搜索相关数据。 例如,您可以使用以下正则表达式查找特定用户已回答的所有问题:

(?<=OwnerUserId="x" )(.*?)(?=ParentId=")(.*?)(?=" PostTypeId="1")

将“x”替换为用户的OwnerUserId值以自定义搜索。 此正则表达式将找到所有具有PostTypeId为“1”(表示它们是问题)和ParentId匹配具有指定OwnerUserId的任何行元素(表示用户已回答问题)的行元素。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM