解析XML文件 [英] Parsing XML file

查看:74
本文介绍了解析XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XML遍历中寻找跟踪Node> Children> SubChildren的技巧或方法。

加载XML不是问题,我有工作代码,当我遍历树,树枝,树枝,树叶时,它正在决定递归的程度。我需要做的是把叶子和枝条分支到分支

(是的,我知道:节点,子节点,子节点等......)


桌子我正在看(简化)

[t_leaves]

[PK] [FK_MM_T2B] [来自叶子的信息]


[MM_T2B]

[PK] [t_Branches] [t_twigs]


[t_twigs]

[PK] [关于树枝的信息]


[t_branches]

[PK] [关于分店的信息]


当我尝试执行简单的外部> XML-Import时,我的可怜的数据库有大约185个基于树中节点的表...非常可悲......并且没有关系将一个表中的数据链接起来接下来。


不,我不知道XML来自哪里。

现在这不是一件紧急的事情在Excel中手动操作数据 - 但这样做很痛苦。


但是,如果我在excel中打开文件,它会将数据放入colu中mns by level等...

因此Col(A)中的组标签跨越该组下的行等...所以我知道XML解析器可以浏览数据。我几乎要实例化Excel,在Excel中打开XML然后走行!但是,我知道有一种优雅的方法,如果我能弄清楚如何解决递归...


这是一个非常简化的XML版本我'我正在处理并且不幸的是信息是保密的。

Looking for tricks or methods of tracking the Node>Children>SubChildren in an XML traverse.

Loading the XML isn''t an issue, I have working code for that, it''s determining the level of recursion as I traverse the tree, branches, twigs, leaves. What I need to do is relate back the Leaves to the Twigs to Branches
(yes, I know: Nodes, Child Nodes, Subchild nodes, etc...)

Tables I''m looking at (simplified)
[t_leaves]
[PK][FK_MM_T2B][Information from the leaf]

[MM_T2B]
[PK][t_Branches][t_twigs]

[t_twigs]
[PK][Information about the twig]

[t_branches]
[PK][information about the branch]

When I tried to do the simple External>XML-Import my poor database had some 185 tables based on the nodes in the tree... very sad indeed... and there were no relationships to link the data in one table to the next.

No, I do not know where the XML came from.
This isn''t an urgent as right now I''m manipulating the data by hand in Excel - but it''s painful to do.

HOWEVER, if I open the file in excel it will place the data in the columns by level, etc...
So a group label in Col(A) spans the rows under that group etc... so I know the XML parser can skim the data. I''m almost to the point of instancing Excel, opening the XML in Excel and then walking the rows! However, I know there is an elegant way of doing this if I can just figure out how to solve tacking the recursion...

This is a Very Simplified version of the XML I''m working with and unfortunately the information is confidential.

展开 | 选择 | Wrap | 行号

推荐答案

我对XML和关于树木和树木的唯一知识如果河流和河流,它们阻挡了我的视线夏天的海。


那说,我可能偏离轨道,我有一个加载网页的例程,然后扫描页面源以获取特定信息。我主要用它来从不同格式的网页中提取股价。它在大多数页面上都能很好地工作,但在某些页面上,信息被埋得更深一些,我想这就是你的子节点进来的地方。


如果这可能有任何帮助,让我知道。


Phil
I know nothing of XML and the only thing I know about Trees & leaves is they block my view if the river & sea in summer.

That said, and I am probably way off track, I have a routine that loads a web page, then scans the page source for a particular piece of information. I use it mainly to extract a share price from differently formatted Web pages. It works perfectly on most pages, but on some pages, the information is buried a little deeper, and I guess that is where your SubNodes come in.

If that could be of any help, let me know.

Phil


早安PhilOfWalton

感谢您的提供。

您抓取网页的代码是否可以将子节点与调用节点的结构中的元素相关联


我认为秘密就是我传递的参数我必须拉下来的下一次递归< UUID>和/或<名称>节点并以同样的方式传递它我跟踪递归级别。


我当前认为主循环可能是(空中代码):

(btw - 来自Web-Search Spiders的蜘蛛名称)
Good Morning PhilOfWalton
Thank you for the offer.
Can the code you have scraping the webpage relate the childnode back to and element in the calling node''s structure

I think the secret is as I am passing the parameters on to the next recursion I have to have pulled <UUID> and/or <Name> node and pass them in the same way I''ve been tracking the recursion level.

My current thought the main loop might be (air code):
(btw - spider name from Web-Search Spiders)
展开 | 选择 | Wrap | 行号


晚上好,zmbd。对不起,正如我对节点说的一样。


我的方法是寻找线索。

所以这里是网页的一部分 https://www.londonstockexchange .com / ... GBGBXSTMM.html

Good Evening, zmbd. Sorry, as I said I nothing about nodes.

My method is to hunt for clues.
so here is a portion of a Web Pagehttps://www.londonstockexchange.com/...GBGBXSTMM.html

展开 | 选择 | Wrap | 行号


这篇关于解析XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆