Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
read xml convert to folder/subfolder/text file
#7
Path() does not support this. When it finds first <SubFolders>, it gets all its children <Folder> and does not search for other <SubFolders>. Standard XPath probably would get all, but QM supports XPath only partially.

In this case need 2 loops.

Macro Macro1797
Code:
Copy      Help
str sXml=
;<?xml version = "1.0"?>
;<Folder-list>
,;<Folder>
,,;<SubFolders>
,,,;<Folder>
,,,,;<Expanded>False1b</Expanded>
,,,,;<Snippets></Snippets>
,,,,;<Title>sub1</Title>
,,,;</Folder>
,,;</SubFolders>
,,;<Title>mainfolder-1</Title>
,;</Folder>
,;<Folder>
,,;<SubFolders>
,,,;<Folder>
,,,,;<Expanded>False2b</Expanded>
,,,,;<Snippets></Snippets>
,,,,;<Title>sub2</Title>
,,,;</Folder>
,,;</SubFolders>
,,;<Title>mainfolder-2</Title>
,;</Folder>
;</Folder-list>

IXml x=CreateXml
x.FromString(sXml)
ARRAY(IXmlNode) b c

;------cycle path-------------
x.Path("/Folder-list/Folder" b)
;------cycle path-------------

int i j
for i 0 b.len
,str titlecheck=b[i].ChildValue("Title")
,if(!empty(titlecheck))
,,out(titlecheck)
,b[i].Path("SubFolders/Folder" c)
,for j 0 c.len
,,titlecheck=c[j].ChildValue("Title")
,,if(!empty(titlecheck))
,,,out(titlecheck)
,,


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)