Welcome! Log In Create A New Profile

Advanced

Further XML file question

Posted by Milton 
Milton
Further XML file question
March 23, 2009 10:43PM
Hi All,

Thanks to some help from the forum I have been able to create and XML document in the format I require. However, I have one problem I still need to solve -

The following code --->>

HReadSeek(jop$,ProductSalesCode,gProdCode)
HReadSeekFirst(pps$,RoomProductNo,jop$.RoomProductNo)
WHILE HFound(pps$)
gPartCode=ExtractString(pps$.Description1,2," ")
XMLAddChild("XMLDoc","ProductCode",""+gPartCode)
XMLAddChild("XMLDoc","Quantity",""+gQuantity)
XMLAddChild("XMLDoc","Configuration","",True)
XMLAddChild("XMLDoc","ConfigurationDetail","",True)
XMLAddChild("XMLDoc","PanelAttributes","",True)
XMLAddChild("XMLDoc","Height",""+pps$.PartLength)
XMLAddChild("XMLDoc","Width",""+pps$.PartWidth)
HReadSeekFirst(pdts$,Description1,pps$.Description1)
gBoardColour=pdts$.Color
gEdgeColour=pdts$.Color
gEdgeTypeTop=Middle(pdts$.LengthMaterial1,3,1)
gEdgeTypeBottom=Middle(pdts$.LengthMaterial2,3,1)
gEdgeTypeLeft=Middle(pdts$.WidthMaterial1,3,1)
gEdgeTypeRight=Middle(pdts$.WidthMaterial2,3,1)
XMLAddChild("XMLDoc","BoardColour",""+gBoardColour)
XMLAddChild("XMLDoc","EdgeSection","",True)
XMLAddChild("XMLDoc","Top","",True)
XMLAddChild("XMLDoc","EdgeType",""+gEdgeTypeTop+"mm")
XMLAddChild("XMLDoc","EdgeColour",""+gEdgeColour)

HReadNext(pps$,RoomProductNo)
END

Generates the XML file as follows -






I want to close the CHILD item <Top> but don't know what command to use to generate the </Top> item in my XML file which would close the child item so that I can do the next iteration.

Can anyone help please?

Milton
DerekT
Re: Further XML file question
March 24, 2009 12:47PM
Milton

If you require a single document with multiple entries from your file browse place
XMLRoot(("XMLDoc") 
before the HReadNext() statement.

If you require a document for each interation then declare a variable as a string and use
 MyString  = XMLBuildString("XMLDoc") 
to create the XML document followed by
 fSaveText("C:\MyPath\+"DocName.xml", MyString) 
to save the doc

Regards

DerekT
Milton
Re: Further XML file question
March 24, 2009 08:04PM
Hi Derek,

Thanks for the reply but I realise I didn't make myself clear. I have done all that you said and can create the XML document but my problem is as shown in the picture below.



I want to be able to close off the <Top> child item before starting my next iteration and whilst I use XMLAddChild to open the <Top> child item I am unsure of how to close it after adding the <EdgeType>, <EdgeColour> etc.

Thanks,

Milton
DerekT
Re: Further XML file question
March 24, 2009 11:43PM
Milton

Not sure I fully understand your requirements but trying to understand your snippet of code I still think that XMLRoot is your answer.

If in your example you place XMLRoot after the XMLAddChild("XMLDoc","EdgeColour",""+gEdgeColour) line then all remaing records written will only contain the tags between "Top" and "/Top"

I am not in the office tomorrow but if this is not what you need and you can let me know were it went wrong I will have a more detailed look on Thursday

Regards

DerekT
Milton
Re: Further XML file question
March 31, 2009 12:24AM
Hi Derek,

Thanks for your reply - I had to go into hospital on Thursday as I broke a tendon in myt foot and I only cam home yesterday. I will give it a try and let you know.

Thanks again for your interest and help.

Milton
DerekT
Re: Further XML file question
March 31, 2009 11:34AM
Milton

Thats bad luck - tendons can be a bit painful I am told.

Regards

DerekT
Milton
Re: Further XML file question
April 02, 2009 07:24AM
Hi Derek,

I have it all worked out now thanks to your help - I was failing to add xmlParent and xmlChild items at the points I was trying to open and close parent and child items. The use of xmlRoot gave me the clue thanks.

Milton
Yaroslav Alpizar.pcs.crosspost
Re: Further XML file question
April 28, 2009 11:23AM
Thanks a lot! this post helped me too! I was having same problem...xmlroot solved all my problems

Message forwarded from pcsoft.us.windev
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: