热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用模式文件提取数据-VBAPullingDatawithaSchemaFile

Ihavethiscodebelow我有下面的代码OptionExplicitSubMadMule2()DimIEAsInternetExplorerD

I have this code below

我有下面的代码

Option Explicit

Sub MadMule2()
    Dim IE As InternetExplorer
    Dim el
    Dim els
    Dim colDocLinks As New Collection
    Dim Ticker As String
    Dim lnk
    Dim intCounter as Integer    

    Set IE = New InternetExplorer

    IE.Visible = False

    Ticker = Worksheets("Sheet1").Range("A1").Value

    LoadPage IE, "https://www.sec.gov/cgi-bin/browse-edgar?" & _
                  "action=getcompany&CIK=" & Ticker & "&type=10-Q" & _
                  "&dateb=&owner=exclude&count=20"

    Set els = IE.document.getElementsByTagName("a")
    For Each el In els
        If Trim(el.innerText) = "Documents" Then
            colDocLinks.Add el.href
        End If
    Next el

    intCounter = 1

     For Each lnk In colDocLinks
        LoadPage IE, CStr(lnk)
        For Each el In IE.document.getElementsByTagName("a")
            If el.href Like "*[0-9].xml" Then
                ActiveWorkbook.XmlMaps.Add(el, "xbrl").Name = "xbrl Map"
            End If
        Next el
    Next lnk
End Sub

Sub LoadPage(IE As InternetExplorer, URL As String)
    IE.navigate URL
    Do While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
End Sub

This comment of user2140261

这评论user2140261


Also why are you using the XML files to get the Schema when your website already has one made for you? Doesn't make sense to let excel guess at making one when there is already one made. AS excel could do it wrong and you might never catch its mistakes.

还有,为什么您的网站已经为您制作了模式,而您却要使用XML文件来获取模式?让excel在已有产品的情况下进行猜测是没有意义的。正如excel可能会做错,你可能永远不会发现它的错误。


got me into trying to create an XML Map into Excel by using the data agency's Schema by simply changing this statement:

让我尝试通过使用数据代理的模式创建一个XML映射到Excel,只需更改以下语句:

If el.href Like "*.xsd" Then

and this statement

这个声明

ActiveWorkbook.XmlMaps.Add(el, "Schema").Name = "xbrl Map " & intCounter 

However when i am trying to do it (by going to XML task pane, pushing Source and then XML Maps) I get this:

然而,当我尝试做它(通过访问XML任务窗格,推源和XML映射)时,我得到了这个:

enter image description here

How is this possible? I open the Schema file and is see that the root node is one and it is Schema

这怎么可能?我打开模式文件,看到根节点是1,它是模式

enter image description here

While it is reasonable that : ...Doesn't make sense to let excel guess at making one (Excel makes a Schema for you when you import only an XML file) when there is already one made.

虽然有理由:……让excel猜测一个(当您只导入一个XML文件时,excel为您创建一个模式)是没有意义的,因为已经生成了一个XML文件。

When i imported the XML file i had one root node made. This was the root node xbrl and it made quite easy for me to understand things. Now i get the fragmentation seen in the first picture plus an amazingly long running time.

当我导入XML文件时,生成了一个根节点。这是根节点xbrl,我很容易理解。现在我看到了第一张图片中出现的碎片加上一个令人惊讶的长时间运行。

  • Do you believe i should/must refer to different root nodes when i want to import different data?

    当我想导入不同的数据时,您认为我应该/必须引用不同的根节点吗?

  • How could i use the ready-made schema of the data agency which guards me against mistake?

    如何使用数据代理的现成模式来防止错误?

  • How can i put all of these nodes under one root node (as excel does when i import in XML Maps the XML file) instead of having many root nodes and at the same time use the Schema?

    我如何将所有这些节点放在一个根节点下(当我导入XML映射XML文件时,excel就会这样做),而不是有很多根节点,同时使用模式?

I hope this edit of the question doesn't turn into a heavy fiasco for me again as the solution for the former 3 edits of this question-thread was rather before my eyes.

我希望这个问题的编辑对我来说不会变成一个严重的惨败,因为前三次对这个问题的编辑的解决方案就在我眼前。

1 个解决方案

#1


1  

The XML-Schema that is referenced on that site is a hell of a beast (considering XML-Schema is prone to beastly constructs). This schema imports several additional schemas (further down, xs:import ...) what might explain the additional schemas available.

在该站点上引用的XML-Schema简直就是一头猛兽(考虑到XML-Schema很容易产生糟糕的结构)。该模式导入了几个额外的模式(进一步向下,xs:import…),这可能解释了可用的其他模式。

On the other hand: Although the automatic XML-Schema generated by Excel is indeed sometimes not complete or fully accurate (types) I would use this schema nevertheless -- if necessary with some corrections (see Exporting XML from Excel and Keeping Date Format).

另一方面:尽管Excel生成的自动XML模式有时确实不完整或不完全准确(类型),但我还是会使用这个模式——如果需要修改的话(参见从Excel导出XML和保持日期格式)。

Apart from that I couldn't figure out what you were trying to accomplish, although using MSXML to download the files seems a very reasonable advise.

除此之外,我不知道您想要完成什么,尽管使用MSXML下载文件似乎是一个非常合理的建议。

Sorry for the superficial answer. I hope it helps nonetheless or gives some clues. Andreas

很抱歉给你一个肤浅的回答。我希望它能有所帮助或提供一些线索。安德烈亚斯


推荐阅读
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
author-avatar
一克拉白勺的眼泪
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有