[英]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="<p>one question;/a></p>
" OwnerUserId="67" LastEditorUserId="254" LastEditDate="2017-06-12T15:04:30.633" LastActivityDate="2017-06-12T15:04:30.633" Title="title" Tags="<discussion><faq><allowed-questions><tags><traditions>" 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="<p>another question.</li>
</ul>
" 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="<p>an answer/p>
" 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="<p>I answer.</p>
" 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="<p>answer</p>
" OwnerUserId="67" LastEditorUserId="254" LastEditDate="2014-10-10T19:58:18.847" LastActivityDate="2014-10-10T19:58:18.847" Title="title" Tags="<discussion><site-promotion><beta>" 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="<p>answer.</p>
" 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="<answer. </p>
" 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.