Where there are funky characters in the XML file,DOMDocument->load complained about them, saying that they weren’t UTF-8, and to specify the encoding.
For example,
Warning: DOMDocument::loadXML(): Input is not proper UTF-8, indicate encoding !
Bytes: 0xE4 0x3C 0x2F 0x66 in Entity, line: 1 in test.php on line 6
with doc->recover=false(default) : failed
Solution:
<?php
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->load($xmlPath);
?>
Edit: Since it appears that this doesn't work, what you could do instead is similar to your existing method but without the temp file. Read the XML file from your source just using standard IO operations (file_get_contents() or something), then perform whatever changes to the encoding you need (iconv() or utf8_decode()) and then use loadXML()
<?php
$myXMLString = file_get_contents($xmlPath);
$myXMLString = utf8_decode($myXMLString);
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->loadXML($myXMLString);
?>
For example:
<?php
function getNodeValue($dom, $tagName, $nodeName)
{
$notificationNodeList = $dom->getElementsByTagName($tagName);
if (($notificationNodeList->length == 1) && $notificationNodeList->item(0)->hasChildNodes())
{
foreach($notificationNodeList->item(0)->childNodes as $node)
{
if ($node->nodeName == $nodeName)
return trim($node->nodeValue);
}
}
return "";
}
$xmlStr = utf8_decode($xmlStr);
$dom = new DomDocument('1.0', 'UTF-8');
$dom->loadXml($xmlStr);
$firstname = getNodeValue($dom, 'LicenseeContact', 'cbt:Firstname');
$lastname = getNodeValue($dom, 'LicenseeContact', 'cbt:Lastname');
foreach($dom->getElementsBytagName('Item') as $items):
$m_item[] = $items->getElementsByTagName('ProductId')->item(0)->firstChild->nodeValue;
$powerNum_Quantity[] = $items->getElementsByTagName('Quantity')->item(0)->firstChild->nodeValue;
$YourCurrencyId[]=$items->getElementsByTagName('YourCurrencyId')->item(0)->firstChild->nodeValue;
endforeach;
?>
Hi, i feel that i noticed you visited my weblog so i came to go back the prefer?.I’m trying to find issues to improve my website!I assume its good enough to use some of your concepts!!
You are in point of fact a just right webmaster. The site loading velocity is amazing. It seems that you’re doing any distinctive trick. Furthermore, The contents are masterpiece. you’ve done a fantastic activity in this topic!
It is actually a great and useful piece of info. I’m happy that you just shared this useful information with us. Please stay us informed like this. Thank you for sharing.
I will immediately seize your rss as I can’t to find your e-mail subscription link or e-newsletter service. Do you have any? Kindly let me realize in order that I could subscribe. Thanks.
Gems form the internet…
[...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……
Tumblr article…
I saw a writer writing about this on Tumblr and it linked to…
Blogs ou should be reading…
[...]Here is a Great Blog You Might Find Interesting that we Encourage You[...]……
Check this out…
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……
Related……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……
You should check this out…
[...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]……
Great website…
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]…
yenibinet…
this was a sheer entertaining read….
Best Ways To Find Optometrist…
[...]When you know when doing your work you will do more than when you have no ideas…[...]…
Sources…
[...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……
WoW Gold…
Attractive section of content. I just stumbled upon your website and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I’ll be subscribing to your augment and even I achievement you access consistently fast….
Websites you should visit…
[...]below you’ll find the link to some sites that we think you should visit[...]……
Fens Teli…
Emre Aydin…
2011…
I have read several good stuff here. Certainly worth bookmarking for revisiting. I surprise how much effort you put to make such a wonderful informative site….
sohbet odaları…
canlı sohbet…