Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [xml] Problem z zapisem
Forum PHP.pl > Forum > XML, AJAX > XML
flashion
Witam.
Mój problem wygląda tak. Mam sobie 2 pliki - skrypt.php i tomek.xml

skrypt.php
Kod
<?php
    $xml = new DOMDocument;
    $xml->load("tomek.xml");
    
    $title = $xml->createElement('bb');
    $xml->appendChild($title);

    $xml->formatOutput = true;
    $xml->saveXML();

    $xml->save("tomek.xml");
?>


uruchamiam skrypt. za pierwszym razem wszystko działa. ale za drugim wyskakuje błąd:
Cytat
Warning: DOMDocument::load() [function.DOMDocument-load]: Extra content at the end of the document in file:///E%3A/Program%20Files/WebServ/httpd/tomek.xml, line: 132 in E:\Program Files\WebServ\httpd\skrypt.php on line 3


a w xmlu pokazuje się:
Cytat
Błąd parsowania XML: niezrozumiała seria znaków po elemencie dokumentu
Obszar: http://localhost/tomek.xml
Numer linii 132, kolumna 1:<bb/>
^


co jest z tym znakiem "po" elemencie?
c3zi
To może pokaż jeszcze jak wygląda plik tomek.xml.
flashion
Kod
<player name="Gm tOOfast" id="1" account="111111" sex="2" lookdir="2" exp="1812321" voc="4" level="999" access="5" groupflags="0" cap="0" maglevel="8" soul="100" maxdepotitems="1000" lastlogin="1194283744" skullticks="0">
<spawn x="945" y="940" z="7"/>
<temple x="793" y="1014" z="7"/>
<health now="800" max="800"/>
<mana now="240" max="240" spent="1187930"/>
<look type="264" head="0" body="0" legs="0" feet="0" addons="0"/>
<guild name="" rank="" nick="" id="0"/>

    <skills>
<skill skillid="0" level="10" tries="0"/>
<skill skillid="1" level="10" tries="0"/>
<skill skillid="2" level="92" tries="51295"/>
<skill skillid="3" level="10" tries="0"/>
<skill skillid="4" level="10" tries="0"/>
<skill skillid="5" level="92" tries="78862"/>
<skill skillid="6" level="62" tries="836"/>
</skills>

    <addons>
<addon outfit="252" type="3"/>
<addon outfit="253" type="3"/>
</addons>
<deaths/>
<blessings/>

    <inventory>

    <slot slotid="1">
<item id="2480"/>
</slot>

    <slot slotid="3">

    <item id="1988">

    <inside>
<item id="2456"/>
<item id="2190"/>
<item id="2544" count="100"/>
<item id="2389" count="1"/>
<item id="2456"/>
<item id="2544" count="72"/>
<item id="1294" count="20"/>
<item id="7378" count="100"/>
<item id="2455"/>
<item id="2336"/>
<item id="2152" count="98"/>
<item id="2152" count="2"/>
<item id="2445"/>
<item id="2190"/>
<item id="2392"/>
<item id="2207" duration="1690000"/>
</inside>
</item>
</slot>

    <slot slotid="4">
<item id="2656"/>
</slot>

    <slot slotid="5">
<item id="2396" count="1"/>
</slot>

    <slot slotid="6">
<item id="2536"/>
</slot>

    <slot slotid="7">
<item id="2647"/>
</slot>

    <slot slotid="10">
<item id="2547" count="1"/>
</slot>
</inventory>

    <depots>

    <depot depotid="4294967196">

    <item id="2589">

    <inside>
<item id="2594"/>
</inside>
</item>
</depot>

    <depot depotid="7">

    <item id="2589">

    <inside>
<item id="2594"/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 7 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 6 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 4 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 3 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 2 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 1 days, or you will lose this house."/>
<item id="2415"/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 6 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 5 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 4 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 3 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 2 days, or you will lose this house."/>
<item id="2598" text="Warning!
The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 1 days, or you will lose this house."/>
<item id="2160" count="100"/>
</inside>
</item>
</depot>

    <depot depotid="2">

    <item id="2589">

    <inside>
<item id="2594"/>
</inside>
</item>
</depot>

    <depot depotid="1">

    <item id="2590">

    <inside>
<item id="2594"/>
<item id="2667" count="50"/>
<item id="2666" count="47"/>
<item id="2160" count="100"/>
<item id="2160" count="45"/>
<item id="2543" count="55"/>
<item id="2534"/>
</inside>
</item>
</depot>
</depots>

    <storage>
<data key="5030" value="1"/>
<data key="5031" value="1"/>
<data key="5032" value="1"/>
<data key="5033" value="1"/>
<data key="5034" value="1"/>
<data key="5041" value="1"/>
</storage>
<viplist/>
<knownspells/>

    <conditions>
<condition type="256" id="0" ticks="1285500" lightcolor="215" lightlevel="11" lightticks="78000" lightinterval="136363"/>
<condition type="8192" id="-1" ticks="441000" healthticks="3000" healthgain="50" manaticks="6000" managain="20"/>
<condition type="16" id="0" ticks="7500" delta="574" mina="0.7" minb="-56" maxa="0.7" maxb="-56"/>
</conditions>
</player>
c3zi
To zobacz sobie teraz jaki bajzel z cudzysłowami masz w kodzie, od lini 97 ..
flashion
no i?
c3zi
no jak no i ?

Masz coś takiego:
  1. <item id="2594"/>
  2. <item id="2598" text="Warning!
  3. The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 7 days, or you will lose this house."/>
  4. <item id="2598" text="Warning!
  5. The weekly rent of 10000 gold for your house "Folda House III" is payable. Have it available within 6 days, or you will lose this house."/>
  6. ...
  7. ...
  8. ...


Zrób coś takiego:
  1. <item id="2594"/>
  2. <item id="2598" text="Warning! The weekly rent of 10000 gold for your house 'Folda House III' is payable. Have it available within 7 days, or you will lose this house."/>
  3. <item id="2598" text="Warning! The weekly rent of 10000 gold for your house 'Folda House III' is payable. Have it available within 6 days, or you will lose this house."/>
  4. ...
  5. ...
  6. ...
flashion
wszystko już w porządku. wystarczyło zmienić linijkę z appenChild na:
Kod
$xml->documentElement->appendChild($title);


dzięki za fatygę
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.