Jump to content

Xml obj read child and subchild help


Recommended Posts

I need help to read in a loop the DVD id child and subchild. Thx

Example...

DVD001 - PAL - EN,FR,DE,ES,IT and filter the right title & descri language.  I tried with $oXML.SelectSingleNode but without success

<?xml version="1.0" encoding="UTF-8"?>
<datafile xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mydvd.xsd">  
    <dvd name="My dvd title">
        <id>DVD001</id>
        <region>PAL</region>
        <languages>EN,FR,DE,ES,IT</languages>
        <locale lang="EN">
            <title>title en</title>
            <descri>descri en</descri>
        </locale>
        <locale lang="FR">
            <title>title fr</title>
            <descri>descri fr </descri>
        </locale>
        <locale lang="DE">
            <title>title de</title>
            <descri>descri de </descri>
        </locale>
        <locale lang="ES">
            <title>title es</title>
            <descri>descri es</descri>
        </locale>
        <locale lang="IT">
            <title>title it</title>
            <descri>descri it</descri>
        </locale>
    </dvd>
    <dvd name="My dvd title 2">
        <id>DVD002</id>
        <region>USA</region>
        <languages>EN</languages>
        <locale lang="EN">
            <title>title en</title>
            <descri>descri en</descri>
        </locale>
    </dvd>
</datafile>
#include <File.au3>

$xml = @ScriptDir&"\test.xml"

Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($xml)

$id = $oXML.SelectNodes("//dvd")

For $ids In $id
    ConsoleWrite($ids.text  &@CRLF)
Next

 

Edited by rootx
Link to comment
Share on other sites

I fixed one question... but I need to understand how to read subchild in the correct order <locale lang=EN>... FR... etc.... THX

#include <File.au3>

$xml = @ScriptDir&"\test.xml"

Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($xml)

$oParameters = $oXML.SelectNodes("//dvd")
For $oParameter In $oParameters
    $id = $oParameter.SelectSingleNode("./id")
    $region = $oParameter.SelectSingleNode("./region")
    $languages = $oParameter.SelectSingleNode("./languages")
    $locale = $oParameter.SelectSingleNode("./locale");<--------------------------------
    ConsoleWrite($id.text &" -- "& String($region.text) &" -- "& $languages.text &" -- "& $locale.text &@CRLF)
Next

This result is incomplete:

DVD001 -- PAL -- EN,FR,DE,ES,IT -- title en descri en
DVD002 -- USA -- EN -- title en descri en

My goal is

DVD001 -- PAL -- EN,FR,DE,ES,IT -- title en -- descri en -- title fr -- descri fr -- ETC......

How can I explode an read al child locale?? THX

Link to comment
Share on other sites

Use .SelectNodes on the locale, and then loop through what's returned...you can continually add into the same variable by $sLocale &= $oBlah.text

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...