i try to get some value from xml file and yhe value was i get is "0" all the time this is my code:
<?php
$xml=simplexml_load_file("SwiftNess_21911904_1.xml")or die("Error: Cannot create object");
print_r((string)$xml->KoteretKovetz[0]->KOD-SHOLEACH);
?>
and this is the xml file:
<Mimshak>
<KoteretKovetz>
<SUG-MIMSHAK>1</SUG-MIMSHAK>
<MISPAR-GIRSAT-XML>006</MISPAR-GIRSAT-XML>
<TAARICH-BITZUA>20171025155621</TAARICH-BITZUA>
<KOD-SVIVAT-AVODA>2</KOD-SVIVAT-AVODA>
<KIVUN-MIMSHAK-XML>4</KIVUN-MIMSHAK-XML>
<KOD-SHOLEACH>520024647</KOD-SHOLEACH>
<SHEM-SHOLEACH>כלל חברה לביטוח בע"מ</SHEM-SHOLEACH>
<KOD-MEZAHE-METAFEL>520024647</KOD-MEZAHE-METAFEL>
<SHEM-METAFEL>כלל חברה לביטוח בע"מ</SHEM-METAFEL>
<MEZAHE-HAAVARA>004000520024647CONSLTING006201710251556553252.DAT</MEZAHE-HAAVARA>
<MISPAR-HAKOVETZ>20171025155655520024647</MISPAR-HAKOVETZ>
</KoteretKovetz>
<YeshutYatzran>...</YeshutYatzran>
<ReshumatSgira>...</ReshumatSgira>
</Mimshak>
According to the PHP manual:
Accessing elements within an XML document that contain characters not permitted under PHP's naming convention (e.g. the hyphen) can be accomplished by encapsulating the element name within braces and the apostrophe.
Therefore:
print_r((string)$xml->KoteretKovetz[0]->{'KOD-SHOLEACH'});