09-24-2018, 09:16 PM
I want to add to "EPP/Bookmarks"
To a node that is "closed"
<Bookmarks />
The result should be:
Look at the below code and green comments (below green comment 'Actual result' and 'Desired result' , regarding <Bookmarks />)
Macro Macro9
<Bookmark name="TESTNAME" Description="" Type="1" ShowOnBookmarksToolbar="yes" Location="C:\test"/>
To a node that is "closed"
<Bookmarks />
The result should be:
...
<Bookmarks>
<Bookmark name="TESTNAME" Description="" Type="1" ShowOnBookmarksToolbar="yes" Location="C:\test"/>
</Bookmarks>
...
Look at the below code and green comments (below green comment 'Actual result' and 'Desired result' , regarding <Bookmarks />)
Macro Macro9
str addnode="Bookmark" ;; This node get's added to 'EPP/Bookmarks'
;; Note here that 'Bookmark' is closed ==> <Bookmarks />
str xml_source=
;<?xml version="1.0" ?>
;<EPP>
,;<Bookmarks />
,;<ApplicationToolbar>
,,;<ApplicationButton name="test" Command="c:\test.txt" ShowNameOnToolbar="yes" />
,;</ApplicationToolbar>
,;<Toolbars>
,,;<Toolbar name="0" id="0" Style="641" Length="281" />
,,;<Toolbar name="1" id="3" Style="640" Length="629" />
,;</Toolbars>
;</EPP>
IXml x._create
IXmlNode e
x.FromString(xml_source)
int i
e=x.Path("EPP/Bookmarks")
e.Add(addnode)
e.SetAttribute("name" "TESTNAME")
e.SetAttribute("Description" "")
e.SetAttribute("Type" "1")
e.SetAttribute("ShowOnBookmarksToolbar" "yes")
e.SetAttribute("Location" "c:\test")
str s
x.ToString(s)
out s
;Actual result:
;----------------------------------
;<?xml version="1.0" ?>
;<EPP>
,;<Bookmarks name="TESTNAME" Description="" Type="1" ShowOnBookmarksToolbar="yes" Location="c:\test">
,,;<Bookmark />
,;</Bookmarks>
,;<ApplicationToolbar>
,,;<ApplicationButton name="test" Command="c:\test.txt" ShowNameOnToolbar="yes" />
,;</ApplicationToolbar>
,;<Toolbars>
,,;<Toolbar name="0" id="0" Style="641" Length="281" />
,,;<Toolbar name="1" id="3" Style="640" Length="629" />
,;</Toolbars>
;</EPP>
;Desired result:
;----------------------------------
;<?xml version="1.0" ?>
;<EPP>
,;<Bookmarks>
,,;<Bookmark name="TESTNAME" Description="" Type="1" ShowOnBookmarksToolbar="yes" Location="C:\test"/>
,;</Bookmarks>
,;<ApplicationToolbar>
,,;<ApplicationButton name="test" Command="c:\test.txt" ShowNameOnToolbar="yes" />
,;</ApplicationToolbar>
,;<Toolbars>
,,;<Toolbar name="0" id="0" Style="641" Length="281" />
,,;<Toolbar name="1" id="3" Style="640" Length="629" />
,;</Toolbars>
;</EPP>