Results 1 to 10 of 10

Thread: Read XML file

Hybrid View

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880

    Read XML file

    Hi all,
    I'm working with a XML file, but I've a problem..
    Name:  2018-12-14 08_33_57-Window.jpg
Views: 189
Size:  124.9 KB

    I've a XML file with strange structure..

    I' open the file:
    lsFile = "C:\Users\Fabio\Documents\Lavoro\CEGEKA\Linak\Fatt ureInput\201812\LAVERDA XML.xml"
    XQUERY_OPEN(lsFile)

    I read all the nodes
    oNodes = xquery_node("ConditionalArea")
    ? xml_decode(oNodes)

    but I don't see all the nodes.. the nodes with the same name are skipped...

    How can I read all the nodes?

    thanks
    Fabio

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,767
    Why is this question in the Lianja App Center forum?

    I will move it TO Visual FoxPro scripting in Lianja.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,767
    Please submit a ticket and attach the XML file.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880
    Ok, thanks
    Fabio

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,767
    Please read the xquery doc again.

    https://www.lianja.com/doc/index.php/XQUERY_OPEN()
    https://www.lianja.com/doc/index.php/XQUERY_DECODE()
    https://www.lianja.com/doc/index.php...Y_ATTRIBUTES()
    https://www.lianja.com/doc/index.php/XQUERY_SELECT()

    Example code to read your XML file using xquery notation.

    Code:
    xquery_open("c:\barry\LAVERDA XML.xml")
    local cnt = xquery_count("/report/ConditionalArea/BodySalesTable")
    for i=1 to cnt
        ? xquery_node("/report/ConditionalArea/BodySalesTable[&i]/LineHeader")
    endfor
    ?
    xquery_close()
    And the output...

    Name:  Screen Shot 2018-12-17 at 4.54.54 PM.jpg
Views: 53
Size:  32.2 KB
    Last edited by barrymavin; 2018-12-17 at 04:27.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880
    Hi Barry, thanks.
    This is like my first test code.. but I've some subnode not present every time:
    eg:
    node1
    subnode1-1
    subnode2-1
    node2
    subnode1-2
    subnode2-2
    node3
    node4
    subnode1-4
    node5
    ...
    ..


    with this kind of file, I think the only solution is to be read the file witha a low level XML funcions...

    loXML = CREATEOBJECT('MSXML2.DomDocument')

    thanks
    Fabio

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,767
    Quote Originally Posted by phabio View Post
    Hi Barry, thanks.
    This is like my first test code.. but I've some subnode not present every time:
    eg:
    node1
    subnode1-1
    subnode2-1
    node2
    subnode1-2
    subnode2-2
    node3
    node4
    subnode1-4
    node5
    ...
    ..


    with this kind of file, I think the only solution is to be read the file witha a low level XML funcions...

    loXML = CREATEOBJECT('MSXML2.DomDocument')

    thanks
    Fabio
    Itís all working for me and I gave you sample code. Your solution is windows only not cross platform. Rather than tell me it doesnít work show me what doesnít work. I already give you the doc links so you can better understand how the xquery functions work.

  8. #8
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880
    But now I try again..

    thank

  9. #9
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880
    Ok,
    but it's the ML file wryte in a wrong format..

    thanks
    Fabio

  10. #10
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,880
    Just to know, Barry fixed a bug in record time and the creation of custom XML with the activex loXML = createobject ('MSXML2.DOMDocument') works perfectly.

    Thanks Barry!

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us