SimpleXML - namespaces

shabbir4it

New Member
My XML is structured like this:\[code\] <MLineItem z:Id="i46"> <CBalance>9282.000000000000000000000000</CBalance> <Date>2011-04-01T00:00:00</Date> <LTotal>1083.333333333333333333333333</LTotal> <OBalance>8198.666666666666666666666667</OBalance> <TFees>1083.3333333333333333333333333</TFees> <TNEF>0</TNEF> <TPayments>0</TPayments> <TVouchers>0</TVouchers><TForXml> <LItem z:Id="i47" i:type="FLineItem"> <CBalance>9282.000000000000000000000000</CBalance> <Date>2011-04-01T00:00:00</Date> <LTotal>1083.333333333333333333333333</LTotal> <OBalance>8198.666666666666666666666667</OBalance>\[/code\]----note --- Below does not parse to SIMPLE XML, but is apart of the original XML query.\[code\] <FMonth z:Id="i48"> <d6p1:CCost>1083.3333333333333333333333333</d6p1:CCost> <d6p1:Date>2011-04-01T00:00:00</d6p1:Date> <d6p1:DMonth z:Id="i49"> <d6p1:QForSDiscount>false</d6p1:QForSDiscount> <d6p1:TDiscount>0</d6p1:TDiscount> </d6p1:DMonth> <d6p1:FSMonths> <d6p1:FSMonth z:Id="i50" /> </d6p1:FSMonths> <d6p1:NCalculator z:Id="i51"> <d6p1:Contribution>0</d6p1:Contribution> </d6p1:NCalculator> <d6p1:TSCost>1083.3333333333333333333333333</d6p1:TSCost> </FMonth> </LItem> </TForXml> </MLineItem>\[/code\]Here is my Simple XML Object:\[code\] [3] => SimpleXMLElement Object ( [CBalance] => 3705.00000 [Date] => 2010-11-01T00:00:00 [LTotal] => 1235.00000 [OBalance] => 2470.00000 [TFees] => 1235.00000 [TNEF] => 0 [TPayments] => 0 [TVouchers] => 0 [TForXml] => SimpleXMLElement Object ( [LItem] => SimpleXMLElement Object ( [CBalance] => 3705.00000 [Date] => 2010-11-01T00:00:00 [LTotal] => 1235.00000 [OBalance] => 2470.00000 [FMonth] => SimpleXMLElement Object ( ) ) ) )\[/code\]Here is my Simple XML code in PHP:\[code\] //tidy up the xml $config = array( 'input-xml' => true, 'output-xml' => true, 'indent' => true, 'wrap' => false, 'numeric_entities' => true, ); $tidy = tidy_parse_string($response, $config); $tidy->cleanRepair(); //create new simpleXML element $xml = new SimpleXMLElement($tidy);\[/code\]I suspect the reason why it is not working is because of this:\[code\] <d6p1:QForSDiscount>false</d6p1:QForSDiscount>\[/code\]d6p1 - name spaces. How can I get my simple xml object to parse them too?Cheers.
 
Back
Top