Skip to main content

I am trying to build a struct to convert to XML using structtoxml. I've got various bits in place using $tags, but I'm having difficulty coding something to build this XML output. 


Delivery Note

I've tried. 

v_struct->DeliveryNoteHead->DeliveryNoteType = "Delivery Note"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code="ASN"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code->$tags->xmlClass="attribute"

Which returns


Delivery Note

Even though the struct $dbgstring is 

[]
[DeliveryNoteHead]
[DeliveryNoteType]
"Delivery Note"
[Code] = "ASN"
[$tags]
[xmlClass] = "attribute"

I've also tried 

v_struct->DeliveryNoteHead->DeliveryNoteType = $newstruct
v_struct->DeliveryNoteHead->DeliveryNoteType->Code="ASN"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code->$tags->xmlClass="attribute"

Which gives me 



How do I get to the element "value", is it a special tag? 

I've also tried setting it after the $newstruct and after the "Code" attribute, but in both cases I think it wipes the current struct. 

I've tried setting an element in the struct with no name (DeliveryNoteType→"") , which is ignored... 

Help!

Iain

I am trying to build a struct to convert to XML using structtoxml. I've got various bits in place using $tags, but I'm having difficulty coding something to build this XML output. 


Delivery Note

I've tried. 

v_struct->DeliveryNoteHead->DeliveryNoteType = "Delivery Note"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code="ASN"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code->$tags->xmlClass="attribute"

Which returns


Delivery Note

Even though the struct $dbgstring is 

[]
[DeliveryNoteHead]
[DeliveryNoteType]
"Delivery Note"
[Code] = "ASN"
[$tags]
[xmlClass] = "attribute"

I've also tried 

v_struct->DeliveryNoteHead->DeliveryNoteType = $newstruct
v_struct->DeliveryNoteHead->DeliveryNoteType->Code="ASN"
v_struct->DeliveryNoteHead->DeliveryNoteType->Code->$tags->xmlClass="attribute"

Which gives me 



How do I get to the element "value", is it a special tag? 

I've also tried setting it after the $newstruct and after the "Code" attribute, but in both cases I think it wipes the current struct. 

I've tried setting an element in the struct with no name (DeliveryNoteType→"") , which is ignored... 

Help!

Iain

With these cases I don't think at all. I simply write something like this

VC_XML = $xml
xmltostruct VS_XML, VC_XML

xml:blockdata @
Delivery Note
@

To see what happen.

Then, I rebuild structure.


In this case, the problem is the order of assignments. If you put (using $scalar)

v_struct->DeliveryNoteHead->DeliveryNoteType->$scalar = "Delivery Note"

after the assignment of Code attribute it will work.

Even without $tags "document" or "element", the result will be the expected.


Regards


With these cases I don't think at all. I simply write something like this

VC_XML = $xml
xmltostruct VS_XML, VC_XML

xml:blockdata @
Delivery Note
@

To see what happen.

Then, I rebuild structure.


In this case, the problem is the order of assignments. If you put (using $scalar)

v_struct->DeliveryNoteHead->DeliveryNoteType->$scalar = "Delivery Note"

after the assignment of Code attribute it will work.

Even without $tags "document" or "element", the result will be the expected.


Regards

I was working from the original xml converted to another struct, it was the $scalar I was missing