The GW-Scripting list is a discussion list for information regarding the development and use of Window-Eyes scripts. Any subscriber of the GW-Scripting list has the ability to post on-topic messages.
From:
David <trailerdavid@hotmail.com>Subject:
Writing Data To An XML - I am stuck...Date:
Wed, Apr 3, 2013 12:17:18 pmThis is a multi-part message in MIME format.
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)
Content-type: text/plain; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
I have been playing around a bit, the last few days, trying to learn the XML structure a bit more deeply. One of my projects, will need to store information in an XML registry, since that will make more tidy conditions, than would an ini file.
Yes, I have done several searches on the net, mainly finding information on how to retrieve info from an XML file. I then thought of the UI design app from GW, which does update XML files frequently, when operated. Maybe I could grasp some good ideas from there, to get things going. And, yes, it sure did point me in the right direction. So far, my app does save an XML registry, and I can easily have it update the registry with new entries.
Still, I am stuck on one point. I have tried to think through this one, and as I said, scrolled through the UI Design app code, hoping to grasp the meaning of what I am doing wrong. Still, cannot figure. Now I hoped, that someone of you could have a quick look, and get me on the right path.
Thing is, that it keeps "multiplying" certain lines in the XML file. To illustrate it all, here follows the app code, along with the output results. Anyone see where I am lost? :)
Sub RegisterProduct( ProductSection, ProductName)
Dim ProductRegistryFilename: ProductRegistryFilename = ClientInformation.ScriptPath &"ProductList.xml"
Dim ProductXML: Set ProductXML = CreateObject( "MSXML2.DOMDocument.6.0")
ProductXml.preserveWhiteSpace = True
ProductXML.Load( ProductRegistryFilename)
Dim DocElem : Set DocElem = ProductXML.documentElement
If DocElem Is Nothing Then
ProductXML.LoadXML( "<Products></Products>")
Dim pi : Set pi = ProductXML.createProcessingInstruction("xml", "version='1.0'")
ProductXML.insertBefore pi, ProductXML.documentElement
End If 'DocElem Is Nothing.
Dim Kind: Set Kind = ProductXML.CreateElement( ProductSection)
ProductXML.DocumentElement.AppendChild Kind
' Product name:
Dim Name: Set Name = ProductXML.CreateElement( "Name")
Name.Text = Productname
Kind.AppendChild Name
' Save the Product Registration Card to the XML registry:
ProductXML.Save ProductRegistryFilename
' Room-cleaning:
If Not ProductXML Is Nothing Then Set ProductXML = Nothing
If Not Kind Is Nothing Then Set Kind = Nothing
If Not Name Is Nothing Then Set Name = Nothing
End Sub 'RegisterProduct.
If now, I call this sub with the following lines:
RegisterProduct "Computer", "HP"
RegisterProduct "Computer", "Dell"
RegisterProduct "Printer", "Canon"
The resulting XML file, will look like this:
<Products>
<Computer>
<Name>HP</Name>
</Computer>
<Computer>
<Name>Dell</Name>
</Computer>
<Printer>
<Name>Cannon</Name>
</Printer>
</Products>
My big issue here is, why in the world the two entries under Computer, does produce seperate "Computer" sections. I would have expected the whole computer section of the XML, to have looked like this:
<Computer>
<Name>HP</Name>
<Name>Dell</Name>
</Computer>
Obviously, I am overlooking something, and doing things the wrong way. Kind of frustrating, when you are that close, and yet cannot figure why things get stuck. Anyone out there please, who could kick me on the right track? :)
As always, thanks for any feedback.
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)
Content-type: text/html; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19403">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>I have been playing around a bit, the last few
days, trying to learn the XML structure a bit more deeply. One of my projects,
will need to store information in an XML registry, since that will make more
tidy conditions, than would an ini file.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Yes, I have done several searches on the net,
mainly finding information on how to retrieve info from an XML file. I then
thought of the UI design app from GW, which does update XML files frequently,
when operated. Maybe I could grasp some good ideas from there, to get things
going. And, yes, it sure did point me in the right direction. So far, my app
does save an XML registry, and I can easily have it update the registry with new
entries.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Still, I am stuck on one point. I have tried to
think through this one, and as I said, scrolled through the UI Design app code,
hoping to grasp the meaning of what I am doing wrong. Still, cannot figure. Now
I hoped, that someone of you could have a quick look, and get me on the right
path.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Thing is, that it keeps "multiplying" certain lines
in the XML file. To illustrate it all, here follows the app code, along with the
output results. Anyone see where I am lost? :)</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Sub RegisterProduct( ProductSection,
ProductName)<BR> Dim ProductRegistryFilename: ProductRegistryFilename ClientInformation.ScriptPath &"ProductList.xml"<BR> Dim ProductXML:
Set ProductXML = CreateObject(
"MSXML2.DOMDocument.6.0")<BR> ProductXml.preserveWhiteSpace True</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> ProductXML.Load(
ProductRegistryFilename)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> Dim DocElem : Set DocElem ProductXML.documentElement<BR> If DocElem Is Nothing
Then<BR> ProductXML.LoadXML(
"<Products></Products>")<BR> Dim pi : Set pi ProductXML.createProcessingInstruction("xml",
"version='1.0'")<BR> ProductXML.insertBefore pi,
ProductXML.documentElement<BR> End If 'DocElem Is Nothing.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> Dim Kind: Set Kind ProductXML.CreateElement(
ProductSection)<BR> ProductXML.DocumentElement.AppendChild
Kind</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Product name:<BR> Dim Name: Set Name ProductXML.CreateElement( "Name")<BR> Name.Text Productname<BR> Kind.AppendChild Name</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Save the Product Registration Card to the XML
registry:<BR> ProductXML.Save ProductRegistryFilename</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Room-cleaning:<BR> If Not ProductXML Is
Nothing Then Set ProductXML = Nothing<BR> If Not Kind Is Nothing
Then Set Kind = Nothing<BR> If Not Name Is Nothing Then Set Name
= Nothing<BR>End Sub 'RegisterProduct.</FONT></DIV>
<DIV> </DIV><FONT size=2 face=Arial>
<DIV><BR>If now, I call this sub with the following lines:</DIV>
<DIV> </DIV>
<DIV>RegisterProduct "Computer", "HP"<BR>RegisterProduct "Computer",
"Dell"<BR>RegisterProduct "Printer", "Canon"</DIV>
<DIV> </DIV>
<DIV>The resulting XML file, will look like this:</DIV>
<DIV> </DIV>
<DIV><Products><BR> <Computer><BR> <Name>HP</Name><BR> </Computer><BR> <Computer><BR> <Name>Dell</Name><BR> </Computer><BR> <Printer><BR> <Name>Cannon</Name><BR> </Printer><BR></Products></DIV>
<DIV> </DIV>
<DIV>My big issue here is, why in the world the two entries under Computer, does
produce seperate "Computer" sections. I would have expected the whole computer
section of the XML, to have looked like this:</DIV>
<DIV> </DIV>
<DIV> <Computer><BR> <Name>HP</Name><BR> <Name>Dell</Name><BR> </Computer></DIV>
<DIV> </DIV>
<DIV>Obviously, I am overlooking something, and doing things the wrong way. Kind
of frustrating, when you are that close, and yet cannot figure why things get
stuck. Anyone out there please, who could kick me on the right track? :) </DIV>
<DIV> </DIV>
<DIV>As always, thanks for any feedback.</FONT></DIV></BODY></HTML>
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)--
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)
Content-type: text/plain; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
I have been playing around a bit, the last few days, trying to learn the XML structure a bit more deeply. One of my projects, will need to store information in an XML registry, since that will make more tidy conditions, than would an ini file.
Yes, I have done several searches on the net, mainly finding information on how to retrieve info from an XML file. I then thought of the UI design app from GW, which does update XML files frequently, when operated. Maybe I could grasp some good ideas from there, to get things going. And, yes, it sure did point me in the right direction. So far, my app does save an XML registry, and I can easily have it update the registry with new entries.
Still, I am stuck on one point. I have tried to think through this one, and as I said, scrolled through the UI Design app code, hoping to grasp the meaning of what I am doing wrong. Still, cannot figure. Now I hoped, that someone of you could have a quick look, and get me on the right path.
Thing is, that it keeps "multiplying" certain lines in the XML file. To illustrate it all, here follows the app code, along with the output results. Anyone see where I am lost? :)
Sub RegisterProduct( ProductSection, ProductName)
Dim ProductRegistryFilename: ProductRegistryFilename = ClientInformation.ScriptPath &"ProductList.xml"
Dim ProductXML: Set ProductXML = CreateObject( "MSXML2.DOMDocument.6.0")
ProductXml.preserveWhiteSpace = True
ProductXML.Load( ProductRegistryFilename)
Dim DocElem : Set DocElem = ProductXML.documentElement
If DocElem Is Nothing Then
ProductXML.LoadXML( "<Products></Products>")
Dim pi : Set pi = ProductXML.createProcessingInstruction("xml", "version='1.0'")
ProductXML.insertBefore pi, ProductXML.documentElement
End If 'DocElem Is Nothing.
Dim Kind: Set Kind = ProductXML.CreateElement( ProductSection)
ProductXML.DocumentElement.AppendChild Kind
' Product name:
Dim Name: Set Name = ProductXML.CreateElement( "Name")
Name.Text = Productname
Kind.AppendChild Name
' Save the Product Registration Card to the XML registry:
ProductXML.Save ProductRegistryFilename
' Room-cleaning:
If Not ProductXML Is Nothing Then Set ProductXML = Nothing
If Not Kind Is Nothing Then Set Kind = Nothing
If Not Name Is Nothing Then Set Name = Nothing
End Sub 'RegisterProduct.
If now, I call this sub with the following lines:
RegisterProduct "Computer", "HP"
RegisterProduct "Computer", "Dell"
RegisterProduct "Printer", "Canon"
The resulting XML file, will look like this:
<Products>
<Computer>
<Name>HP</Name>
</Computer>
<Computer>
<Name>Dell</Name>
</Computer>
<Printer>
<Name>Cannon</Name>
</Printer>
</Products>
My big issue here is, why in the world the two entries under Computer, does produce seperate "Computer" sections. I would have expected the whole computer section of the XML, to have looked like this:
<Computer>
<Name>HP</Name>
<Name>Dell</Name>
</Computer>
Obviously, I am overlooking something, and doing things the wrong way. Kind of frustrating, when you are that close, and yet cannot figure why things get stuck. Anyone out there please, who could kick me on the right track? :)
As always, thanks for any feedback.
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)
Content-type: text/html; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19403">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>I have been playing around a bit, the last few
days, trying to learn the XML structure a bit more deeply. One of my projects,
will need to store information in an XML registry, since that will make more
tidy conditions, than would an ini file.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Yes, I have done several searches on the net,
mainly finding information on how to retrieve info from an XML file. I then
thought of the UI design app from GW, which does update XML files frequently,
when operated. Maybe I could grasp some good ideas from there, to get things
going. And, yes, it sure did point me in the right direction. So far, my app
does save an XML registry, and I can easily have it update the registry with new
entries.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Still, I am stuck on one point. I have tried to
think through this one, and as I said, scrolled through the UI Design app code,
hoping to grasp the meaning of what I am doing wrong. Still, cannot figure. Now
I hoped, that someone of you could have a quick look, and get me on the right
path.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Thing is, that it keeps "multiplying" certain lines
in the XML file. To illustrate it all, here follows the app code, along with the
output results. Anyone see where I am lost? :)</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Sub RegisterProduct( ProductSection,
ProductName)<BR> Dim ProductRegistryFilename: ProductRegistryFilename ClientInformation.ScriptPath &"ProductList.xml"<BR> Dim ProductXML:
Set ProductXML = CreateObject(
"MSXML2.DOMDocument.6.0")<BR> ProductXml.preserveWhiteSpace True</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> ProductXML.Load(
ProductRegistryFilename)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> Dim DocElem : Set DocElem ProductXML.documentElement<BR> If DocElem Is Nothing
Then<BR> ProductXML.LoadXML(
"<Products></Products>")<BR> Dim pi : Set pi ProductXML.createProcessingInstruction("xml",
"version='1.0'")<BR> ProductXML.insertBefore pi,
ProductXML.documentElement<BR> End If 'DocElem Is Nothing.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial> Dim Kind: Set Kind ProductXML.CreateElement(
ProductSection)<BR> ProductXML.DocumentElement.AppendChild
Kind</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Product name:<BR> Dim Name: Set Name ProductXML.CreateElement( "Name")<BR> Name.Text Productname<BR> Kind.AppendChild Name</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Save the Product Registration Card to the XML
registry:<BR> ProductXML.Save ProductRegistryFilename</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>' Room-cleaning:<BR> If Not ProductXML Is
Nothing Then Set ProductXML = Nothing<BR> If Not Kind Is Nothing
Then Set Kind = Nothing<BR> If Not Name Is Nothing Then Set Name
= Nothing<BR>End Sub 'RegisterProduct.</FONT></DIV>
<DIV> </DIV><FONT size=2 face=Arial>
<DIV><BR>If now, I call this sub with the following lines:</DIV>
<DIV> </DIV>
<DIV>RegisterProduct "Computer", "HP"<BR>RegisterProduct "Computer",
"Dell"<BR>RegisterProduct "Printer", "Canon"</DIV>
<DIV> </DIV>
<DIV>The resulting XML file, will look like this:</DIV>
<DIV> </DIV>
<DIV><Products><BR> <Computer><BR> <Name>HP</Name><BR> </Computer><BR> <Computer><BR> <Name>Dell</Name><BR> </Computer><BR> <Printer><BR> <Name>Cannon</Name><BR> </Printer><BR></Products></DIV>
<DIV> </DIV>
<DIV>My big issue here is, why in the world the two entries under Computer, does
produce seperate "Computer" sections. I would have expected the whole computer
section of the XML, to have looked like this:</DIV>
<DIV> </DIV>
<DIV> <Computer><BR> <Name>HP</Name><BR> <Name>Dell</Name><BR> </Computer></DIV>
<DIV> </DIV>
<DIV>Obviously, I am overlooking something, and doing things the wrong way. Kind
of frustrating, when you are that close, and yet cannot figure why things get
stuck. Anyone out there please, who could kick me on the right track? :) </DIV>
<DIV> </DIV>
<DIV>As always, thanks for any feedback.</FONT></DIV></BODY></HTML>
--Boundary_(ID_USlnEZtCEBPUKNnDJ5LOnw)--




