inactive Posted June 9, 2008 Share Posted June 9, 2008 Hey guys I'm using SimpleXMLElement to process an XML file thats in pretty bad shape (probably not really conforming properly). Anyway its throwing all sorts or errors when it gets to an empty field such as this: <sf:Cover_Details__c xsi:nil="true"/> The rest of the file looks like this, and works fine: <?xml version='1.0' standalone='yes'?> </custdetail> <Customer_Email__c>name@domain</Customer_Email__c> <Customer_First_Name__c>Rebecca</Customer_First_Name__c> <Customer_Last_Name__c>Test</Customer_Last_Name__c> </custdetail> It seems to process it into array/SimpleXMLElement objects correctly, but throws up a heap of warnings for the empty (nil) fields along the way: Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: namespace error : Namespace prefix xsi for nil on Cover_Details__c is not defined in D:\server\Apache\htdocs\_test.php on line 20 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: ...<Cover_Details__c xsi:nil="true" in D:\server\Apache\htdocs\_test.php on line 20 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: ^ in D:\server\Apache\htdocs\_test.php on line 20 Does anyone have a clue about XML shemas and the like, cause I certainly dont? How do I supress these errors and get the empty fields processed OK? I'd be quite happy to pre-process it all and turn the empty/nil fields into <fieldname></fieldname> format to help it work, using a regex or something, but I really wouldnt know how to go about that either... Any suggestions, or even links to tutes would be great, thanks heaps guys. Link to comment https://forums.phpfreaks.com/topic/109387-simplexmlelement-regex-solution/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.