login about faq

I'vd successfully used your email, ftp, and zip products for years. Now i'm trying to create an XML document using the ActiveX latest version of Chilkat. I do not know how to create a subnode off a Child node. Ex: create the address, city, statecode, postalcode, countrycode inside child2 ContactAddress and PhoneNumber inside child2 Phone.

<contact contacttype="Both"> <contactaddress>

1234 Oak Street
<city>Tallahassee</city> <statecode>FL</statecode> <postalcode>32304</postalcode> <countrycode>USA</countrycode> </contactaddress> <phone> <phonenumber>9995551212</phonenumber> </phone> </contact>

I've attached my current XML output, the XML i'm trying to model, and the FoxPro code i'm currently using...

Thanks...

My OutPut:

<batchdataset xmlns="http://www.slclearinghouse.com/XMLSchema/SLBatchFiling" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaversion="1.4" submissiontype="CHSLFiling"> <reportingentity> <nationalproducernumber>12345</nationalproducernumber> <emailaddress>testemail@sampledomain.com</emailaddress> </reportingentity> <contact contacttype="Both"> <firstname>Brian</firstname> <lastname>Smith</lastname> <emailaddress>testemail@sampledomain.com</emailaddress> <contactaddress/> <phone/> <fax>8505551213</fax> </contact> </batchdataset>

What I’m trying to duplicate (child subNode highlighted in Yellow):

<batchdataset xmlns="http://www.slclearinghouse.com/XMLSchema/SLBatchFiling" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaversion="1.4" submissiontype="CHSLFiling"> <reportingentity> <nationalproducernumber>12345</nationalproducernumber> <emailaddress>smith@slclearinghouse.com</emailaddress> </reportingentity> <contacts> <contact contacttype="Both"> <firstname>Brian</firstname> <lastname>Smith</lastname> <emailaddress>testemail@sampledomain.com</emailaddress> <contactaddress>
1234 Oak Street
<city>Tallahassee</city> <statecode>FL</statecode> <postalcode>32304</postalcode> <countrycode>USA</countrycode> </contactaddress> <phone> <phonenumber>8505551212</phonenumber> </phone> <fax>8505551213</fax> </contact> </contacts>

My Code in FoxPro:

LOCAL loXml LOCAL loChildNode

loXml = CreateObject('Chilkat_9_5_0.Xml') loXml1= CreateObject('Chilkat_9_5_0.Xml') loXml.Tag = "BatchDataSet" loXml.AddAttribute("xmlns","http://www.slclearinghouse.com/XMLSchema/SLBatchFiling") loXml.AddAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance") loXml.AddAttribute("SchemaVersion","1.4") loXml.AddAttribute("SubmissionType","CHSLFiling") loChildNode = loXml.NewChild("ReportingEntity","") loChildNode.NewChild2("NationalProducerNumber",uplxml1.v1cust1) loChildNode.NewChild2("EmailAddress",ALLTRIM((uplxml1.v1email1)))

loChildNode = loXml.NewChild("Contact","") loChildNode.AddAttribute("ContactType","Both") loChildNode.NewChild2("FirstName",ALLTRIM((uplxml1.firstname))) loChildNode.NewChild2("LastName",ALLTRIM((uplxml1.lastname))) loChildNode.NewChild2("EmailAddress",ALLTRIM((uplxml1.v1email1))) loChildNode.NewChild2("ContactAddress","") Need to do subNode here… loChildNode.NewChild2("Phone","") Need to do subNode here… loChildNode.NewChild2("Fax",ALLTRIM((uplxml1.v1fax1)))

asked Jun 28 '16 at 19:01

BGT1212's gravatar image

BGT1212
31

Thanks Tracy. That's what i'm currently doing - if I create a new child, it does not create it under the current child but start it's own node. NewChild2 will create a second level nested node but I don't know how to created a third level, fourth level...

(Jun 28 '16 at 22:19) BGT1212

I've typed up a quick example

LOCAL loXml as Chilkat_v9_5_0.ChilkatXml, loChildNode1, loChildNode2
loxml = CREATEOBJECT('Chilkat_9_5_0.Xml')
loxml.Tag = "BatchDataSet"
loChildNode1 = loXml.NewChild("Contact","")
loChildNode2 = loChildNode1.NewChild("ContactAddress", "")
loChildNode2.NewChild2("subNode","value")
?loXml.GetXml()

This is the output I get from it

<?xml version="1.0" encoding="utf-8" ?>
<BatchDataSet>
    <Contact>
        <ContactAddress>
            <subNode>value</subNode>
        </ContactAddress>
    </Contact>
</BatchDataSet>

link

answered Jun 29 '16 at 00:20

TracyP's gravatar image

TracyP
1213

Thank you so much! That's exactly what I was trying to do! Works great! I do love Chilkat products!

(Jun 29 '16 at 12:07) BGT1212

I believe you would use NewChild to create the ContactAddress node. Then you will be able to continue adding new child nodes to it.

Tracy

link

answered Jun 28 '16 at 22:02

TracyP's gravatar image

TracyP
1213

i'm using the NewChild but it will not place this node under a previously created node (Contact) but starts it's own level; if I use NewChild2 I can only nest one more level. I need to be able to nest to a third and fourth level...

loChildNode = loXml.NewChild("Contact","") loChildNode = loXml.NewChild("ContactAddress","")

(Jun 28 '16 at 23:32) BGT1212
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×65
×18
×6

Asked: Jun 28 '16 at 19:01

Seen: 541 times

Last updated: Jun 29 '16 at 12:07

powered by OSQA