Robs Programming Junk
Welcome to my programming blog!With some luck you will find some tasty nuggets of information here. If you do find something please post a comment on where or how you used it. I like to see what sort of impact my work has on others.
Wednesday, May 17, 2006
VFP: Inserting Nodes with XML Object
This was not a fun experiment. The key here is that we are using Visual Foxpro
to insert into a XML document. We do this by selecting the parent node, then insert
into the child nodes at a specific location. I dont see any other way to optimize this but I'm open for suggestions.
to insert into a XML document. We do this by selecting the parent node, then insert
into the child nodes at a specific location. I dont see any other way to optimize this but I'm open for suggestions.
* OPEN MSXML Object
xmlDoc=CREATEOBJECT("Msxml2.DOMDocument.6.0")
xmlDoc.ASYNC="false"
xmlDoc.LOAD("xmltest.xml")
x=xmlDoc.documentElement
* INit document fragment
docFrag = xmlDoc.CreateDocumentFragment()
* Set the XML
docFrag.appendChild(xmlDoc.CreateElement("REF_J"))
* Obtain Original Node where children Exist
oNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300")
i=0
* Object Creation Of children nodes to iterate
objChildNodes = oNode.ITEM(0).childNodes
* Iterate through children, identify the node you want to insert before
FOR EACH strNode IN objChildNodes
** NODE IDENTIFIED, DO INSERT
IF strNode.nodename="REF_K"
* Inserting at the location of the node with children, insert before the location of the child node.
oNode.ITEM(0).insertBefore(docFrag, oNode.ITEM(0).childNodes.ITEM(i))
EXIT FOR
ENDIF
i=i+1
NEXT
* Save XML
xmlDoc.SAVE("xmltest-output.xml")
Comments:
Links to this post: << Home
Good news, I found a faster way to make it work.
oNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300")
oBNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300/REF_K")
oNode.ITEM(0).insertBefore(docFrag, oBNode.Item(0))
And this works too
oBNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300/REF_K")
oBNode.Item(0).parentnode.insertBefore(docFrag, oBNode.Item(0))
Post a Comment
oNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300")
oBNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300/REF_K")
oNode.ITEM(0).insertBefore(docFrag, oBNode.Item(0))
And this works too
oBNode=xmlDoc.selectnodes("/recordset/L.2000B/L.2300/REF_K")
oBNode.Item(0).parentnode.insertBefore(docFrag, oBNode.Item(0))
Links to this post: << Home
View my portfolio at iFreelance.com
Hire MechSoftware for Quality Assurance (QA), Database Programming, and Security Design/Programming
Find QA Freelance Jobs at iFreelance.com
Hire MechSoftware for Quality Assurance (QA), Database Programming, and Security Design/Programming
Find QA Freelance Jobs at iFreelance.com
Recent Posts
Linux: Dell Latitude LM, XWindows, Neomagic Magicg...
CIO Blogs - Could "Found Code" Cripple Your Compan...
Links for .NET security info
TechToolBlog 195 Free Online Programming Books
Convert String to Byte Array
Sql Server Row Size Limit - Rick Strahl's WebLog
Visual Studio Express
VB.NET: Base 36 Function
BLOGGER: You can use GeSHi in your blogger posts
LINUX: wget
Archives
01/01/2005 - 02/01/200502/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
04/01/2006 - 05/01/2006
05/01/2006 - 06/01/2006
09/01/2006 - 10/01/2006
10/01/2006 - 11/01/2006
11/01/2006 - 12/01/2006
12/01/2006 - 01/01/2007
04/01/2007 - 05/01/2007
05/01/2007 - 06/01/2007
01/01/2008 - 02/01/2008
02/01/2008 - 03/01/2008
05/01/2008 - 06/01/2008
06/01/2008 - 07/01/2008
08/01/2008 - 09/01/2008
09/01/2008 - 10/01/2008
11/01/2008 - 12/01/2008
12/01/2008 - 01/01/2009
01/01/2009 - 02/01/2009
02/01/2009 - 03/01/2009
04/01/2009 - 05/01/2009
05/01/2009 - 06/01/2009
07/01/2009 - 08/01/2009
01/01/2010 - 02/01/2010
My Software
Blinky - GBPVR PluginPhotoCopy - GBPVR Plugin
QTC - Quick Test Case
rBoop - Rob's Timers
Programming Links
C# FormatterNSIS
Other Links
Damn Small LinuxSites I Manage
Do it yourself SEO. Cheap.Pet Supplies
Dog toy of the month club
SqueakerZ pet Deals
Geocaching Community
Hitch hiker Tracking
