XML DOM - Attribute auslesen ...

  • hi leute,
    ich will ein par daten aus einem xml file lesen.
    hab das bislang mit string-operationen gemacht, bis ich xml-dom entdeckt habe.
    leider komm ich damit überhaupt nicht zurecht.

    so sieht der zu parsende file aus:
    <?xml version="1.0" encoding="UTF-8"?>
    <profiles>
    <profile guid="{5C8A76D1-3CE1-4B69-989F-4B349314C5E6}" name="sample_10" revision="3.06" lock="0">
    <description>
    Description here ...
    </description>
    </profile>
    </profiles>

    1. wie lese ich die attribute guid, name, revision und lock aus (mit XML dom) ??
    _XMLGetAttrib('//profiles/profile/',$aAttrName,$aAttrValue ) scheint nicht zu funzen..

    2. wie lese ich eine mehrzeilige spalte ein, wenn z.b. description mehrzeilig ist??

    merci mal!!

    ps die version von xml dom ist von 2007 is das okay?

  • sorry was meinst du mit udf?

    bislang für multilines:
    $tmp1 = StringSplit($text, "<script>",1)
    $tmp2 = StringSplit($tmp1[2], "</script>",1)

    $p1a = $tmp1[1]
    $p1b = $tmp2[2]
    $p1 = $p1a & $p1b
    $p2 = change2($tmp2[1])

    oder für argumente eines tags:
    $tmp = _StringExplode($header, '"')
    ;Find Header Parameters
    $P_GUID = $tmp[1] & ".lgp"
    $P_NAME = $tmp[3]
    $P_REVI = $tmp[5]
    $P_LOCK = $tmp[7]

    wie lese ich die argumente mit xml-dom ein?

  • okay, also ich komme langsam hinter das system, vermisse aber irgendwie ne readme oder so. einige tuts dazu sind leider off ...
    ich kann jeztzt die attribute auslesen, wenn ich sie kenne mit
    $p_guid = _XMLGetAttrib('/profiles/profile','guid')
    $p_name = _XMLGetAttrib('/profiles/profile','name')
    $p_lock = _XMLGetAttrib('/profiles/profile','lock')

    oder ein feld mit
    $p_description = _XMLGetValue('/profiles/profile/description')


    aber wie geht das wenn ich die attribute nicht kenne????

    EDIT: aha!

    Dim $names[10], $values[10], $f
    $f = _XMLGetAllAttrib('profiles/profile',$names,$values)

    .. okay .. hab glaub ich die kurve bekommen ... thx

    Einmal editiert, zuletzt von UPIA (14. April 2011 um 22:17)