小编Ple*_*Guy的帖子

Python XML解析

*注意:lxml将无法在我的系统上运行.我希望找到一个不涉及lxml的解决方案.

我已经在这里浏览了一些文档,并且我很难按照我的意愿开始工作.我想解析一些看起来像这样的XML文件:

<dict>
    <key>1375</key>
    <dict>
        <key>Key 1</key><integer>1375</integer>
        <key>Key 2</key><string>Some String</string>
        <key>Key 3</key><string>Another string</string>
        <key>Key 4</key><string>Yet another string</string>
        <key>Key 5</key><string>Strings anyone?</string>
    </dict>
</dict>
Run Code Online (Sandbox Code Playgroud)

在我试图操纵的文件中,有更多的"dict"跟随这个.我想通读XML并输出一个如下所示的text/dat文件:

1375,"Some String","Another String","又一个字符串","Strings any?"

...

EOF

**最初,我尝试使用lxml,但经过多次尝试让它在我的系统上工作,我继续使用DOM.最近,我尝试使用Etree来完成这项任务.对于所有善良的爱,请有人帮助我吗?我是Python的新手,想了解它是如何工作的.我提前谢谢你.

python xml parsing lxml

9
推荐指数
2
解决办法
3万
查看次数

如何使用 Powershell 指定收件箱的子文件夹

我正在尝试使用 Powershell 访问 Outlook(2010)中名为“子文件夹”的“收件箱”子文件夹。

$olFolderInbox = 6
$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder($olFolderInbox)

# how do I specify a subfolder that's inside Inbox???
# I mean, "Inbox\subfolder" where "subfolder" is the name of the subfolder...
Run Code Online (Sandbox Code Playgroud)

我如何指定这个子文件夹?

我确信这真的很简单,这就是为什么我即将“失去它”。提前致谢!

*稍后在我的代码中,我在正文中搜索“searchterm”,如果匹配,则将结果发送到文本文件。以下代码适用于我的收件箱:

$inbox.items | foreach {
if($_.body -match "searchterm") {$_.body | out-file -encoding ASCII foo.txt} # prints to file...
Run Code Online (Sandbox Code Playgroud)

我想查看收件箱的子文件夹而不是收件箱,如上所述...

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++

编辑:

$olFolderInbox = 6
$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder($olFolderInbox)
$targetfolder = …
Run Code Online (Sandbox Code Playgroud)

powershell outlook

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

lxml ×1

outlook ×1

parsing ×1

powershell ×1

python ×1

xml ×1