以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- xml文件提取问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=175595) |
||||
-- 作者:rjh4078 -- 发布时间:2022/3/10 22:18:00 -- xml文件提取问题 请教各位,想提取这个XML文件的patch节点,使用如下代码,但是有节点报错,循环无法完成,xm文件无法上传修改了后缀名(xml>txt),请教一下这种层层嵌套的如何分解 Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "xml文件|*.xml" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim xml As String = FileSys.ReadAllText(dlg.FileName,Encoding.UTF8) Dim xo As Foxtable.XObject = Foxtable.XObject.Parse(xml)
For Each bm As JToken In xo("Separations")("Separation") Output.show(bm("#text")) For Each yg As JToken In bm("Patches")("Patch") Output.Show(yg("#text")) Next Next End If |
||||
-- 作者:有点蓝 -- 发布时间:2022/3/10 22:45:00 -- 有些Patch节点不是数组 Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim xml As String = FileSys.ReadAllText(dlg.FileName,Encoding.UTF8) Dim xo As Foxtable.XObject = Foxtable.XObject.Parse(xml) For Each bm As JToken In xo("Separations")("Separation") Output.show(bm("#text")) If Typeof bm("Patches")("Patch") Is jobject Output.Show(bm("Patches")("Patch")("#text")) Else For Each yg As JToken In bm("Patches")("Patch") Output.Show(yg("#text")) Next End If Next End If |
||||
-- 作者:rjh4078 -- 发布时间:2022/3/11 9:07:00 -- 多谢 多谢 |
||||
-- 作者:rjh4078 -- 发布时间:2022/3/11 9:32:00 -- Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim xml As String = FileSys.ReadAllText(dlg.FileName,Encoding.UTF8) Dim xo As Foxtable.XObject = Foxtable.XObject.Parse(xml) Output.Show(xo.ToString()) For Each bm As JToken In xo("Separations")("Separation") \'\'Output.show(bm("#text")) If Typeof bm("Patches")("Patch") Is jobject \'\' Output.Show(bm("Patches")("Patch")("#text")) Else For Each yg As JToken In bm("Patches")("Patch") Output.Show(yg("#text")) output.show( yg("Width ")("#text")) Next End If Next End If 蓝版 我想再获取下一级 Width 要怎么获取? 使用yg("Width ")("#text") 提示不存在对象 ,再套循环又不对,麻烦指导一下
|
||||
-- 作者:有点蓝 -- 发布时间:2022/3/11 9:38:00 -- if yg("Width ") isnot nothing then if yg("Width ")("#text") isnot nothing then output.show( yg("Width ")("#text")) end if end if |
||||
-- 作者:rjh4078 -- 发布时间:2022/3/11 9:45:00 -- 感谢 这次可以了 |