XMLReader::readOuterXml

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

XMLReader::readOuterXml β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ XML ΠΈΠ· Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π°, Π²ΠΊΠ»ΡŽΡ‡Π°Ρ сам ΡƒΠ·Π΅Π»

ОписаниС

public function XMLReader::readOuterXml(): string

ΠœΠ΅Ρ‚ΠΎΠ΄ Ρ‡ΠΈΡ‚Π°Π΅Ρ‚ содСрТимоС Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π°, Π²ΠΊΠ»ΡŽΡ‡Π°Ρ сам ΡƒΠ·Π΅Π».

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

Π‘ΠΈΠ³Π½Π°Ρ‚ΡƒΡ€Π° Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ Π½Π΅ содСрТит ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ².

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

ΠœΠ΅Ρ‚ΠΎΠ΄ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ содСрТимоС Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π°, Π²ΠΊΠ»ΡŽΡ‡Π°Ρ сам ΡƒΠ·Π΅Π» ΠΊΠ°ΠΊ строку. ΠœΠ΅Ρ‚ΠΎΠ΄ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΏΡƒΡΡ‚ΡƒΡŽ строку, Ссли Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка.

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ

ΠŸΡ€Π΅Π΄ΠΎΡΡ‚Π΅Ρ€Π΅ΠΆΠ΅Π½ΠΈΠ΅

Π­Ρ‚Π° функция доступна Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ссли PHP скомпилирован с ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΎΠΉ libxml 20620 ΠΈΠ»ΠΈ ΡΡ‚Π°Ρ€ΡˆΠ΅.

Π‘ΠΌΠΎΡ‚Ρ€ΠΈΡ‚Π΅ Ρ‚Π°ΠΊΠΆΠ΅

  • XMLReader::readString() - Π§ΠΈΡ‚Π°Π΅Ρ‚ содСрТимоС Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π° ΠΊΠ°ΠΊ строку
  • XMLReader::readInnerXml() - Π˜Π·Π²Π»Π΅ΠΊΠ°Π΅Ρ‚ XML ΠΈΠ· Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π°
  • XMLReader::expand() - Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ копию Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ ΡƒΠ·Π»Π° Π² Π²ΠΈΠ΄Π΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° DOM
οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 2 notes

up
5
ralf dot horlebein at web dot de ΒΆ
11 years ago
Please note that empty tags like <span></span> will be automatically converted to the short notation <span />.  This could cause trouble in some cases.
up
4
simon at avalon dot net dot nz ΒΆ
15 years ago
Be aware that when you extract a piece of XML from a larger XML document using the readOuterXML() function, it tries to determine the namespaces (as defined in the original XML document) that apply to the new piece, and inserts them into the appropriate tags as xmlns attributes. This can be disconcerting, but it should be a benign alteration in most cases, and I understand that it causes the new chunk of XML to be correctly formatted so it is valid in it's own right. 

As far as I'm aware it's not possible to change this behaviour.