PHP + XML
Moderatori: coditza, Emil, Moderatori
PHP + XML
salut ! ma poate directiona cineva la un tutorial sau sau imi spuna cum as putea adauga noduri in root la un fisier xml existent ? Multumesc anticipat!
-
Daemon7
- PHPRomania Supporter
- Mesaje: 21
- Membru din: Joi Iul 21, 2005 5:22 pm
- Localitate: Timisoara
- Contact:
Poti sa incepi prin a studia un pic functiile de xml DOM din php : http://www.php.net/manual/en/book.domxml.php , http://www.php.net/manual/en/function.d ... lement.php, http://www.php.net/manual/en/book.simplexml.php
-
razvancg
- Junior Member
- Mesaje: 42
- Membru din: Mar Dec 20, 2005 9:14 pm
- Localitate: Cluj-Napoca
- Contact:
pentri eventualele cautari ... recomand xpath ...se poate ajunge oricunde si se poate lua orice informatie dorita din xml
/* Select the first bar child of element foo */
// print_r($foo->xpath('foo/bar[1]'));
/* Select the last bar child of element foo */
// print_r($foo->xpath('foo/bar[last()]'));
/* Select bar elements which have attribute id */
// print_r($foo->xpath('//bar[@id]'));
/* Select bar elements which have any attribute */
// print_r($foo->xpath('//bar[@*]'));
/* Select bar elements without an attribute */
// print_r($foo->xpath('//bar[not(@*)]'));
/* Select all elements with name bar, equivalent with //bar */
// print_r($foo->xpath('//*[name()="bar"]'));
/* Select all elements name of which starts with letter f */
// print_r($foo->xpath('//*[starts-with(name(), "f")]'));
/* Select all elements name of which contain letter f */
// print_r($foo->xpath('//*[contains(name(), "f")]'));
/* Select aaa elements which have attribute name with value foo, leading and
trailing spaces are removed before comparison */
// print_r($foo->xpath('//aaa[normalize-space(@name)="foo"]'));
/* Select elements which have two children bar */
// print_r($foo->xpath('//*[count(bar)=2]'));
/* Select elements which have 2 children */
// print_r($foo->xpath('//*[count(*)=2]'));
/* Select elements with three-letter name */
// print_r($foo->xpath('//*[string-length(name())=3]'));
/* Select all elements bar and eee */
// print_r($foo->xpath('//bar | //eee'));
/* Equivalent of /child::AAA */
// print_r($foo->xpath('//child::aaa/bbb'));
/* Select all elements given in this absolute path */
// print_r($foo->xpath('aaa/bbb/ancestor::*'));
/* Select ancestors of eee element */
// print_r($foo->xpath('//ddd/ancestor::*'));
/* The following-sibling axis contains all the following siblings of the context node. */
// print_r($foo->xpath('/foobar/foo/following-sibling::*'));
/* The preceding-sibling axis contains all the preceding siblings of the context node */
// print_r($foo->xpath('/foobar/aaa/preceding-sibling::*'));
/* The descendant axis contains the descendants of the context node;
a descendant is a child or a child of a child and so on; thus the
descendant axis never contains attribute or namespace nodes */
// print_r($foo->xpath('aaa/bbb/descendant::*'));
/* Select elements ddd which have ccc among its ancestors */
// print_r($foo->xpath('//ccc/descendant::ddd'));
/* The following axis contains all nodes in the same document as the context node that
are after the context node in document order, excluding any descendants and excluding
attribute nodes and namespace nodes. */
// print_r($foo->xpath('/foobar/foo/following::*'));
/* The preceding axis contains all nodes in the same document as the context node that
are before the context node in document order, excluding any ancestors and
excluding attribute nodes and namespace nodes */
// print_r($foo->xpath('aaa/bbb/preceding::*'));
/* Select even bar elements */
// print_r($foo->xpath('//bar[position() mod 2 = 0]'));
/* Select middle bar element(s) */
// print_r($foo->xpath('//bar[position() = floor(last() div 2 + 0.5)]'));
/* Select the first bar child of element foo */
// print_r($foo->xpath('foo/bar[1]'));
/* Select the last bar child of element foo */
// print_r($foo->xpath('foo/bar[last()]'));
/* Select bar elements which have attribute id */
// print_r($foo->xpath('//bar[@id]'));
/* Select bar elements which have any attribute */
// print_r($foo->xpath('//bar[@*]'));
/* Select bar elements without an attribute */
// print_r($foo->xpath('//bar[not(@*)]'));
/* Select all elements with name bar, equivalent with //bar */
// print_r($foo->xpath('//*[name()="bar"]'));
/* Select all elements name of which starts with letter f */
// print_r($foo->xpath('//*[starts-with(name(), "f")]'));
/* Select all elements name of which contain letter f */
// print_r($foo->xpath('//*[contains(name(), "f")]'));
/* Select aaa elements which have attribute name with value foo, leading and
trailing spaces are removed before comparison */
// print_r($foo->xpath('//aaa[normalize-space(@name)="foo"]'));
/* Select elements which have two children bar */
// print_r($foo->xpath('//*[count(bar)=2]'));
/* Select elements which have 2 children */
// print_r($foo->xpath('//*[count(*)=2]'));
/* Select elements with three-letter name */
// print_r($foo->xpath('//*[string-length(name())=3]'));
/* Select all elements bar and eee */
// print_r($foo->xpath('//bar | //eee'));
/* Equivalent of /child::AAA */
// print_r($foo->xpath('//child::aaa/bbb'));
/* Select all elements given in this absolute path */
// print_r($foo->xpath('aaa/bbb/ancestor::*'));
/* Select ancestors of eee element */
// print_r($foo->xpath('//ddd/ancestor::*'));
/* The following-sibling axis contains all the following siblings of the context node. */
// print_r($foo->xpath('/foobar/foo/following-sibling::*'));
/* The preceding-sibling axis contains all the preceding siblings of the context node */
// print_r($foo->xpath('/foobar/aaa/preceding-sibling::*'));
/* The descendant axis contains the descendants of the context node;
a descendant is a child or a child of a child and so on; thus the
descendant axis never contains attribute or namespace nodes */
// print_r($foo->xpath('aaa/bbb/descendant::*'));
/* Select elements ddd which have ccc among its ancestors */
// print_r($foo->xpath('//ccc/descendant::ddd'));
/* The following axis contains all nodes in the same document as the context node that
are after the context node in document order, excluding any descendants and excluding
attribute nodes and namespace nodes. */
// print_r($foo->xpath('/foobar/foo/following::*'));
/* The preceding axis contains all nodes in the same document as the context node that
are before the context node in document order, excluding any ancestors and
excluding attribute nodes and namespace nodes */
// print_r($foo->xpath('aaa/bbb/preceding::*'));
/* Select even bar elements */
// print_r($foo->xpath('//bar[position() mod 2 = 0]'));
/* Select middle bar element(s) */
// print_r($foo->xpath('//bar[position() = floor(last() div 2 + 0.5)]'));
Cine este conectat
Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 6 vizitatori