1

I am stuck with DomDocument

This thing is working fine, no doubt -

$resource1->appendChild($dom->createAttribute('type'))
          ->appendChild($dom->createTextnode("webcontent"));

It is adding type="webcontent" to resource node

However when I am using this code its not adding it to it -

$resource1->appendChild($dom->createAttribute('adlcp:scormType'))
          ->appendChild($dom->createTextnode("sco"));

Expected to generate - adlcp:scormType="sco" <-- Not Working

However If I am creating xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <-- Working

Code -

$manifestNode->appendChild($dom->createAttribute('xmlns:xsi'))
             ->appendChild($dom->createTextNode("http://www.w3.org/2001/XMLSchema-instance"));

Let me know what I am doing wrong and how do I make it working

EDIT

Error -

XML Parsing Error: prefix not bound to a namespace

Googled same with the keyword - xml parsing error prefix not bound to a namespace php but not much help.

1 Answer 1

1

To set an attribute on a node:

$resource1->setAttribute('type', 'webcontent');

To set a namespaced attribute on a node (assuming this is the namespace represented by the "adlcp" prefix):

$resource1->setAttributeNS('http://www.adlnet.org/xsd/adlcp_rootv1p2', 'adlcp:scormType', 'sco');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.