rebol - 如何解析简单的xml文件

标签 rebol rebol3

>> ? xml
No information on xml

parse-xml但在我看来,它是为 Rebol2 准备的。

我在 rebol.org 中搜索了 xml 脚本并找到了 xml-object.r在我看来,这似乎是 all 中最新的。搜索。

我知道altxml也是如此,但给出的示例适用于 html

所以,如果我想解析和使用这种简化结构的+1GB文件的信息,我想问一下我的选择:

<?xml version="1.0" encoding="Windows-1252" standalone="yes"?>
<SalesFile xmlns="urn:StandardSalesFile-1.0">
    <Header>
        <SalesFileVersion>1.01</SalesFileVersion>
        <DateCreation>2014-04-30</DateCreation>
    </Header>
    <SalesInvoices>
        <Invoice>
            <InvoiceNo>INV 1/1</InvoiceNo>
            <DocumentStatus>
                <InvoiceStatus>N</InvoiceStatus>
                <InvoiceStatusDate>2014-01-03T17:57:59</InvoiceStatusDate>
            </DocumentStatus>
        </Invoice>
        <Invoice>
            <InvoiceNo>INV 2/1</InvoiceNo>
            <DocumentStatus>
                <InvoiceStatus>N</InvoiceStatus>
                <InvoiceStatusDate>2014-01-03T17:59:12</InvoiceStatusDate>
            </DocumentStatus>
        </Invoice>
    </SalesInvoices>
</SalesFile>

Rebol3 会有一个 parse-xml 工具吗?我应该使用 xml-object 吗?如果是这样怎么办?因为它仍然超出了我的语言新手水平。其他选择?

最佳答案

还有一个由 Christopher Ross-Gill 编写的名为 alt-xml 的 Rebol 3 库。

http://www.ross-gill.com/page/XML_and_REBOL

这可以将 XML 转换为 block!object! 表示形式。

您的问题表明这些 XML 文件很大,可能无法容纳在主内存中。我建议创建 1GB XML 文件不是最佳实践,因为许多解析器(包括这个解析器)确实尝试将文件加载到内存中。

为了支持这一点,您必须通过在文件上使用 open 来对文件进行分块,并从文件中copy/part 分块。这有点困惑,但它会起作用。

使这个更清晰的一种方法是按照 HostileFork 的建议使用解析,并在解析时修改该系列。 Parse 在这方面非常灵活。

理想情况下,解析能够直接在 port! 对象上工作,但这只是目前的 future 愿望 list 项。

关于rebol - 如何解析简单的xml文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23943925/

相关文章:

rebol - 在一个系列!删除最后一个元素的最佳方法是什么

http - 如何使用 Rebol 3 将 URL 传递给 cookie 并获取响应 cookie?

rebol - 无法上传文件!名义上使用 Rebol

svg - 使用 GOB 的 Rebol 3 文本渲染问题

rebol - 仅使用 SKIP 的 PARSE 中的替代规则未输出预期结果

REBOL 布局 : How to create layout words automatically - word has no context?

filenames - 在 Rebol 3 GUI 中请求文件的正确方法(Saphir 版本)

error-handling - 当我使用错误?并尝试,错误需要一个值

scope - 错误 "word is not bound to a context"是什么意思?