How I can get the element name.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunmt07
    New Member
    • Mar 2008
    • 4

    How I can get the element name.

    Hi ALL,

    Can anyone suggest me how I can get the element name by knowing its attribute value.

    For eg:

    <Channel>
    <US>
    <C100345>
    <Article id="345">
    <Hello>
    </Article>
    </C100345>
    </US>
    </Channel>

    Here I know the attribute id=345 so how I can get its element name?
    If suppose we don't know the attribute value also but we know after channel the element name is US so in this case how I can get its next sibling element name?

    Regards,
    Arun.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    What language are you using? in javascript:
    getElementById( "345").node Name

    --
    xpath
    Channel/US/ something....
    What sibling are you referring to, sibling of Channel, US, or Article?

    Comment

    • arunmt07
      New Member
      • Mar 2008
      • 4

      #3
      Originally posted by jkmyoung
      What language are you using? in javascript:
      getElementById( "345").node Name

      --
      xpath
      Channel/US/ something....
      What sibling are you referring to, sibling of Channel, US, or Article?
      Hi,

      I need to get the element name after <C100345>, that is <Article>
      Here is mentioned element name as Article it can be magazine and article so i need to know weather its magazine or article which is coming from xml.
      I read in one of the post the use of local-name(). How can i do in this?

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        xpath?

        local-name(following: :*[1])
        Last edited by jkmyoung; Mar 12 '08, 05:56 PM. Reason: missed a semicolon

        Comment

        • arunmt07
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by jkmyoung
          xpath?

          local-name(following: *[1])
          Yeah i mean to say xpath.

          Using xslt i have to get that element name from xml file.

          What expression i need to write?

          Comment

          • jkmyoung
            Recognized Expert Top Contributor
            • Mar 2006
            • 2057

            #6
            <xsl:value-of select="local-name(following: :*[1])"/>

            Comment

            • arunmt07
              New Member
              • Mar 2008
              • 4

              #7
              Originally posted by jkmyoung
              <xsl:value-of select="local-name(following: :*[1])"/>
              Hi,

              I tried but it is not working it seems.

              Actually i hav a presentation template which will generate the page in html. This file is of .xml extension.In this template i have given:
              <h1>
              <time:type />
              <h1>

              Then there is a xslt file in which i wrote the code for <time:type />. It is like:
              <xsl:template match="time:typ e" mode="base">
              <xsl:param name="param.con text" tunnel="yes" as="*" />
              <xsl:value-of select = "$param.con text/name()" />
              <xsl:value-of select = "$param.con text/local-name()" />
              <xsl:value-of select = "$param.con text/namespace-uri()" />
              </xsl:template>

              I even tried local-name(following: :*[1]) but both of the expression is not working.
              Pl give some suggestion.
              Thanks.

              Comment

              • jkmyoung
                Recognized Expert Top Contributor
                • Mar 2006
                • 2057

                #8
                Is your template in the xslt, or is it in another xml file altogether?

                Trying to figure out how you're linking this thing.

                Comment

                • indirareddy
                  New Member
                  • Mar 2008
                  • 14

                  #9
                  Hai this is javascript code for hove to get the id value


                  syntax:-

                  var somename=docume nt.getElimentBy Id("Id Name ").value;



                  Example :-

                  var reddy=document. getElimentById( "345 ").value;

                  or

                  var reddy=document. form1.345.value ;

                  Comment

                  Working...