Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 8 Jahren, 6 Monaten
Letzter Beitrag:
vor 8 Jahren, 5 Monaten
Beteiligte Autoren:
Milton, DerekT, Yaroslav Alpizar.pcs.crosspost

Further XML file question

Startbeitrag von Milton am 23.03.2009 21:43

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 but don't know what command to use to generate the item in my XML file which would close the child item so that I can do the next iteration.

Can anyone help please?

Milton

Antworten:

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

von DerekT - am 24.03.2009 11:47
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 child item before starting my next iteration and whilst I use XMLAddChild to open the child item I am unsure of how to close it after adding the , etc.

Thanks,

Milton

von Milton - am 24.03.2009 19:04
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

von DerekT - am 24.03.2009 22:43
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

von Milton - am 30.03.2009 22:24
Milton

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

Regards

DerekT

von DerekT - am 31.03.2009 09:34
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

von Milton - am 02.04.2009 05:24
Thanks a lot! this post helped me too! I was having same problem...xmlroot solved all my problems

Message forwarded from pcsoft.us.windev

von Yaroslav Alpizar.pcs.crosspost - am 28.04.2009 09:23
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.