Jump to content

Recommended Posts

I need to creat an XML with php and have successfully produced a valid output.

The problem I have is that the XML requirements of the application that will import the XML requires that the XML file includes the line:

 

"<OpenShipments xmlns="x-schema:D:/Documents and Settings/VBN5CGC/My Documents/Trainings/xml autoimport WS/pruebas/OpenShipments.xdr">"

 

How do I include this line in my output XML file???

 

here is what I have so far

 

Code:

 

  $doc = new DOMDocument('1.0');

  $doc->formatOutput = true;

 

$root = $doc->createElement('OpenShipments');

$root = $doc->appendChild($root);

 

$occ = $doc->createElement('OpenShipment');

$occ = $root->appendChild($occ);

 

$oc2 = $doc->createElement('ShipTo');

$oc2 = $occ->appendChild($oc2);

 

Output:

 

<OpenShipments>

<OpenShipment>

<ShipTo>

</ShipTo>

</OpenShipment>

</OpenShipments>

 

The requied output is:

 

<OpenShipments xmlns="x-schema:D:/Documents and Settings/VBN5CGC/My Documents/Trainings/xml autoimport WS/pruebas/OpenShipments.xdr">

<OpenShipment>

<ShipTo>

</ShipTo>

</OpenShipment>

</OpenShipments>

 

 

Link to comment
https://forums.phpfreaks.com/topic/176668-creating-xml-with-php/
Share on other sites

thanks for the pointers.

Unfortunately this didn't work:

 

Code:

 

  $doc = new DOMDocument('1.0');
  $doc->formatOutput = true;
  
$root = $doc->createElement('OpenShipments');
$root = $doc->appendChild($root);
$root->setAttribute("xmlns", "x-schema:D:/Documents and Settings/VBN5CGC/My Documents/Trainings/xml autoimport WS/pruebas/OpenShipments.xdr");

 

Output:

 

<OpenShipments>

<OpenShipment>

<ShipTo>

 

 

thanks for the pointers.

Unfortunately this didn't work:

 

Code:

 

  $doc = new DOMDocument('1.0');
  $doc->formatOutput = true;
  
$root = $doc->createElement('OpenShipments');
$root = $doc->appendChild($root);
$root->setAttribute("xmlns", "x-schema:D:/Documents and Settings/VBN5CGC/My Documents/Trainings/xml autoimport WS/pruebas/OpenShipments.xdr");

 

Output:

 

<OpenShipments>

<OpenShipment>

<ShipTo>

 

 

 

not sure if it's this obvious.  I'm still really new to XML files

 

if it's essentially a string though...

$header = '<OpenShipments xmlns="x-schema:D:/Documents and Settings/VBN5CGC/My Documents/Trainings/xml autoimport WS/pruebas/OpenShipments.xdr">';

$doc = $header.$doc;

 

?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.