---
title: "PHP och IF xml"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/156074-php-och-if-xml"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Dykarn"
published: "2007-01-17T19:06:28.000Z"
updated: "2007-01-17T19:06:28.000Z"
replies: 0
views: 198
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/156074-php-och-if-xml"
---

# PHP och IF xml

## #1 — Dykarn, 2007-01-17T19:06Z

Hej vet ej om detta är rätt forum men jag försöker ta reda på om en node finns i en xml fil

```
$xml = ('TDTEST.xml');
$dom->load($xml);

if ($dom->getElementsByTagname('product')->item(0)->firstChild->nodeName =='TDProductId'){
	echo 'Advertiser, yah';
}else{
	echo "Nope, it's the other format";
}
```

 
är koden men den fungerar inte 
xml filen ser ur så här 

```
<?xml version="1.0" encoding="UTF-8"?>
<products>
    <product>
        <TDProductId>xxx</TDProductId>
        <name>xxx</name>
        <description>xxx</description>
        <imageUrl>xxx</imageUrl>
        <productUrl>xxxxxxx)</productUrl>
        <price>12.0</price>
        <currency>GBP</currency>
        <TDCategories>
            <TDCategory>
                <id>xxx</id>
                <name>xxx</name>
                <merchantName>xxx</merchantName>
            </TDCategory>
        </TDCategories>
        <fields/>
    </product>
</products>
```

och det fungerar ej 

någon som har några ideer???

Edit:
om jag flyttar upp 

```
<?xml version="1.0" encoding="UTF-8"?>
<products><product><TDProductId>
```

 
till samma rad utan mellanslag så fungerar det

Permalänk: https://www.webforum.nu/p/156074

---

Tråden på webben: https://www.webforum.nu/amne/php/156074-php-och-if-xml
