Need Parser that can read attributes of XML document...

Discussion in 'XML' started by ChillyRoll@gmail.com, Nov 30, 2006.

  1. Guest

    Hello guys,
    I am looking for a parser in PHP that can return all the
    attributes of XML entities. I know how to read the XML Entities, but I
    have got a problem with reading attributes. So I will appreciate if you
    could give a parser that can return all the Entities and Attributes of
    respective entities as an array.

    For e.g.:

    <?xml version="1.0" ?>
    <Controller>
    <NumberOfBoards>5</NumberOfBoards>
    <NumberOfKeypads>1</NumberOfKeypads>
    <QueueMode>N</QueueMode>
    <EntranceDelay on="5" off="5" />
    <Limits minLength="36" maxLength="800" />
    <Conveyor perSecond="6.3" perPulse="8.0" />
    <Roller relay="1" needsOrder="1">
    <RollerUp1>84</RollerUp1>
    <RollerDown>84</RollerDown>
    <RollerUp2>84</RollerUp2>
    </Roller>
    </Controller>

    This is a part of my XML document. I want to return all the Entites
    with their attributes as an array.

    Thanks in advance.
     
    , Nov 30, 2006
    #1
    1. Advertising

  2. wrote:
    > I am looking for a parser in PHP that can return all the
    > attributes of XML entities


    I think you mean "attributes", not "entities"...?

    I haven't used PHP, but any XML parser should deliver all the
    information available in the document; otherwise, it isn't an XML parser.

    A websearch on "php xml" finds lots of indication that folks are doing
    this and some code examples which are retrieving attributes. "If it
    happens, it must be possible."


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Nov 30, 2006
    #2
    1. Advertising

  3. Guest

    Joe Kesselman wrote:
    > wrote:
    > > I am looking for a parser in PHP that can return all the
    > > attributes of XML entities

    >
    > I think you mean "attributes", not "entities"...?
    >
    > I haven't used PHP, but any XML parser should deliver all the
    > information available in the document; otherwise, it isn't an XML parser.
    >
    > A websearch on "php xml" finds lots of indication that folks are doing
    > this and some code examples which are retrieving attributes. "If it
    > happens, it must be possible."
    >
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry



    Hi Joe,

    First of all, thanks for your immediate reply.

    By Attributes and Entities I mean to say, relating to my XML
    doc, <Controller>, <NumberOfBoards>, <NumberOfKeypads>, <QueueMode>,
    <EntranceDelay, <Limits, <Conveyor, <Roller , <RollerUp1>,
    <RollerDown>, <RollerUp2> are all ENTITIES and in these the ATTRIBUTES
    OF <EntranceDelay > entity are ==>
    on="5" and off="5"

    Similarly there are some other entities that have attributes.

    What I am saying is that, I have searched a net a lot for a parser that
    can return all ENTITIES and ATTRIBUTES as an array, but I didn't get
    any. I have a parser that gives me only ENTITIES and not attributes.

    So can you help me solve this query?

    Thanks again.
     
    , Nov 30, 2006
    #3
  4. strawberry Guest

    wrote:

    > Joe Kesselman wrote:
    > > wrote:
    > > > I am looking for a parser in PHP that can return all the
    > > > attributes of XML entities

    > >
    > > I think you mean "attributes", not "entities"...?
    > >
    > > I haven't used PHP, but any XML parser should deliver all the
    > > information available in the document; otherwise, it isn't an XML parser.
    > >
    > > A websearch on "php xml" finds lots of indication that folks are doing
    > > this and some code examples which are retrieving attributes. "If it
    > > happens, it must be possible."
    > >
    > >
    > > --
    > > () ASCII Ribbon Campaign | Joe Kesselman
    > > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry

    >
    >
    > Hi Joe,
    >
    > First of all, thanks for your immediate reply.
    >
    > By Attributes and Entities I mean to say, relating to my XML
    > doc, <Controller>, <NumberOfBoards>, <NumberOfKeypads>, <QueueMode>,
    > <EntranceDelay, <Limits, <Conveyor, <Roller , <RollerUp1>,
    > <RollerDown>, <RollerUp2> are all ENTITIES and in these the ATTRIBUTES
    > OF <EntranceDelay > entity are ==>
    > on="5" and off="5"
    >
    > Similarly there are some other entities that have attributes.
    >
    > What I am saying is that, I have searched a net a lot for a parser that
    > can return all ENTITIES and ATTRIBUTES as an array, but I didn't get
    > any. I have a parser that gives me only ENTITIES and not attributes.
    >
    > So can you help me solve this query?
    >
    > Thanks again.


    Strange, the xml2Array class over at http://uk2.php.net/xml_parse
    seems to do exactly what you want...

    Array ( [0] =>
    Array ( [name] => CONTROLLER
    [attrs] => Array ( )
    [children] =>
    Array ( [0] =>
    Array ( [name] => NUMBEROFBOARDS
    [attrs] => Array ( )
    [tagData] => 5 )
    [1] =>
    Array ( [name] => NUMBEROFKEYPADS
    [attrs] => Array ( )
    [tagData] => 1 )
    [2] =>
    Array ( [name] => QUEUEMODE
    [attrs] => Array ( )
    [tagData] => N )
    [3] =>
    Array ( [name] => ENTRANCEDELAY
    [attrs] =>
    Array ( [ON] => 5 [OFF] => 5 ) )
    [4] =>
    Array ( [name] => LIMITS
    [attrs] =>
    Array ( [MINLENGTH] => 36
    [MAXLENGTH] => 800 ) )
    [5] =>
    Array ( [name] => CONVEYOR
    [attrs] =>
    Array ( [PERSECOND] => 6.3
    [PERPULSE] => 8.0 ) )
    [6] =>
    Array ( [name] => ROLLER
    [attrs] =>
    Array ( [RELAY] => 1
    [NEEDSORDER] => 1 )
    [children] =>
    Array ( [0] =>
    Array ( [name] => ROLLERUP1
    [attrs] => Array ( )
    [tagData] => 84 )
    [1] =>
    Array ( [name] => ROLLERDOWN
    [attrs] => Array ( )
    [tagData] => 84 )
    [2] =>
    Array ( [name] => ROLLERUP2
    [attrs] => Array ( )
    [tagData] => 84 ) ) ) ) ) )
     
    strawberry, Nov 30, 2006
    #4
  5. > By Attributes and Entities I mean to say, relating to my XML
    > doc, <Controller>, <NumberOfBoards>, <NumberOfKeypads>, <QueueMode>,
    > <EntranceDelay, <Limits, <Conveyor, <Roller> , <RollerUp1>,
    > <RollerDown>, <RollerUp2> are all ENTITIES


    "Entity" has a specific meaning in the XML world, and this isn't it.
    These are Elements. If you want useful answers, it really is helpful to
    use standard terminology when posing the question.



    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Nov 30, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Prichard
    Replies:
    0
    Views:
    791
    Tony Prichard
    Dec 12, 2003
  2. sharan
    Replies:
    4
    Views:
    1,308
    Pavel Lepin
    Nov 5, 2007
  3. Sanjeev
    Replies:
    4
    Views:
    1,493
    Stanimir Stamenkov
    May 4, 2008
  4. arne
    Replies:
    0
    Views:
    378
  5. Sean
    Replies:
    3
    Views:
    345
    robic0
    Oct 3, 2006
Loading...

Share This Page