Parsing Problem

xml

    Next

  • 1. childNodes.Item info by string
    Is it possible to access node information (childNodes.Item().Text) with a string instead of a number? Instead of writing childNodes.Item(3).Text I would like something like this childNodes.Item('Customer').Text How can this be done? Regards Anders Sneckenborg SIMBAL syd AB
  • 2. Creating A New XML DOM Document...
    What is the correct syntax for creating a new XML DOM Document in MSXML 3? Is it: Dim x Set x = Server.CreateObject("MSXML.DOMDocument") How about MSXML 4.0?
  • 3. FSO and XML
    I am downloading and XML file from one of our server using the Microsoft.XMLHTTP and then FSO to re-create the XML file on ta local drive. The file size is running at around 9/10Mb at the moment, taking about 3 mins to create and the file seems to hit an error about 90% in: Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC driver for Oracle]General error Is this an error with Oracle timing out or the Script timing out??? Cheers all!! CHRIS

Parsing Problem

Postby frunny » Tue, 09 May 2006 17:56:43 GMT

Hi all,

I am now sitting here since 1 week and try to get to parse some little
xml with (old) ASP.
Yes, one week and I dont get it - either I think to difficult or I
didnt found the correct resource on the web.
anyway I want to parse this piece of xml

<rsp stat="ok">
	<auth>
		<token>345345-54745577</token>
		<perms>read</perms>
		<user nsid="6453627" username="frunny" fullname="Mr.Frunny"/>
	</auth>
</rsp>

this is a rest response and the xml is fully loaded - i can put it out
in my website with
response.write(server.htmlencode(xmlDom.documentElement.xml))
all is fine until now

now I want to parse it and try to read the "token" amd "perms" first -
but no luck, here is my code:

set nodeCol = xmlDom.documentElement.selectNodes("auth")
for each oNode in nodeCol
  Response.Write(Server.HTMLEncode(oNode.getAttribute("token")))
  Response.Write(Server.HTMLEncode(oNode.getAttribute("perms")))
next

but this will not work I get a type missmatch "htmlencode"
I am totaly stuck into this and read a lot of things on the net but I
dont get it - what is the magic behind this ? It looks easy but it
seams not to.

any tipp or hint will be really great, also about reading the
attributes in the user element
thanks for your help
Andy


Re: Parsing Problem

Postby Anthony Jones » Tue, 09 May 2006 21:13:29 GMT







Your problem is that "token" and "perms" are elements not attributes try:-

  Response.Write(Server.HTMLEncode(GetElementText(oNode, "token")))
  Response.Write(Server.HTMLEncode(GetElementText(oNode, "perms")))


Function GetElementText(roNode, Path)
    Dim oNode
    Set oNode = roNode.selectSingleNode(path)
    If Not oNode is Nothing Then
       GetElementText = oNode.Text
    End If
End Function

Anthony.



Similar Threads:

1.Problem InfoPath Form once deployed (XML Parsing Problem?)

2.XML parsing problem finding a specific element in a specific place

Hi, I have the following XML and I like to grab the node that is in
'List2' and mobilenum=416-222-5435

I have tried the following,
XmlNode xmlNode = xmlDoc.SelectSingleNode(@"/contacts/list
[@name='List2']/contact/@mobilenum=416-222-5435");
and
XmlNode xmlNode = xmlDoc.SelectSingleNode(@"/contacts/list
[@name='List2']/contact/@mobilenum='416-222-5435'");
but I get an error 'Expression must evaluate to a node-set.' Any
idea?

<contacts>
  <list name="list1">
    <contact>
      <name>Name1</name>
      <mobilenum>416-223-3345</mobilenum>
      <email> XXXX@XXXXX.COM </email>
      <profession>Web Manager</profession>
    </contact>
  </list>
  <list name="List2">
    <contact>
      <name>Name2</name>
      <mobilenum>416-222-5435</mobilenum>
      <email>email</email>
      <professionbbbb</profession>
    </contact>
    <contact>
      <name>Name</name>
      <mobilenum>416-223-2342</mobilenum>
      <email>someemail</email>
      <profession>aaaa</profession>
    </contact>
</list>
</contacts>
Thanks
Maz.

3.parsing problem with unicode (utf-16) xml file

hi,

i am trying to open a xml file which is in unicode format utf-16.
the file is

<?xml version="1.0" encoding="UTF-16"?>
<CurrentWeather>
  <Location>Bombay / Santacruz, India (VABB) 19-07N 072-51E
14M</Location>
  <Time>Mar 10, 2006 - 12:40 AM EST / 2006.03.10 0540 UTC</Time>
  <Wind> from the WSW (240 degrees) at 5 MPH (4 KT):0</Wind>
  <Visibility> 1 mile(s):0</Visibility>
  <SkyConditions> partly cloudy</SkyConditions>
  <Temperature> 80 F (27 C)</Temperature>
  <DewPoint> 66 F (19 C)</DewPoint>
  <RelativeHumidity> 61%</RelativeHumidity>
  <Pressure> 29.94 in. Hg (1014 hPa)</Pressure>
  <Status>Success</Status>
</CurrentWeather>

i am using following code to lode the file

	XmlDocument doc  = new XmlDocument();
			doc.Load("C:\\mm.xml");
			XmlDeclaration decl = (XmlDeclaration) doc.FirstChild;
			Console.WriteLine("\n{0}", "XML DECLARTION:");
			Console.WriteLine("{0}", "Version    " + "= " + decl.Version);
			Console.WriteLine("{0}", "Encoding   " + "= " + decl.Encoding);
			Console.WriteLine("{0}", "Standalone " + "= " + decl.Standalone);

but i am getting problem at line 3
the error is thers is no unicode byte order mark.cannot switch to
unicode

please help me

4.XML Parsing Problem

Below I have copied in an xml page I'm trying to parse out and the code
I'm currently using to do it.  My code works great but I want to change
the .Item(0). part of this code to a typed refrence of the child node.
I have tried everything.  How do I search through the xml for these
named child nodes?








        Dim nodelist As XmlNodeList
        Dim node As XmlNode
        Dim temp As String
        nodelist = doc.SelectNodes("/modeminfo/health")
        For Each node In nodelist
            'MsgBox(node.ChildNodes.Item(0).InnerText) ' 10 net
            'MsgBox(node.ChildNodes.Item(1).InnerText) 'Modem State
            'MsgBox(node.ChildNodes.Item(2).InnerText) 'sys desc
            'MsgBox(node.ChildNodes.Item(3).InnerText) 'uptime
            'MsgBox(node.ChildNodes.Item(4).InnerText) 'config file

            temp = Split((node.ChildNodes.Item(5).InnerText),
":")(1).Trim
            txtBrnsTx.Text = temp

            temp = Split((node.ChildNodes.Item(6).InnerText),
":")(1).Trim
            txtBrnsRx.Text = temp 'rx

            temp = Split((node.ChildNodes.Item(7).InnerText),
":")(1).Trim
            txtBrnsSnr.Text = temp 'snr

            temp = Split((node.ChildNodes.Item(8).InnerText),
":")(1).Trim 'resets
            txtBrnsResets.Text = temp

            temp = Split((node.ChildNodes.Item(9).InnerText),
":")(1).Trim 'resets
            txtBrnsLostSyncs.Text = temp

            temp = Split((node.ChildNodes.Item(10).InnerText),
":")(1).Trim 'resets
            txtT3.Text = temp


            'MsgBox(node.ChildNodes.Item(10).InnerText) 't3s
            'MsgBox(node.ChildNodes.Item(11).InnerText) 'healthproctime

        Next


 <?xml version="1.0" ?>
- <modeminfo>
- <health>
  <tennet>10net IP: 10.xx.154.157</tennet>
  <modemstate>Modem alive</modemstate>
  <systemdescription>xxx</systemdescription>
  <uptime>Uptime : (436490525) 50 days, 12 hours 28 mins 25.25
seconds</uptime>
  <configfile>Config File : "e10_m_XX_ccowpe_c10.cm"</configfile>
  <tx>Transmit Level (TX) : 34.5</tx>
- <rx>
  Receive Level (RX) :
  <font color="red">19.0</font>
  </rx>
  <snr>Rx Signal to Noise (SNR): 33.4</snr>
  <resets>Resets : 1</resets>
  <lostsyncs>Lost Syncs : 4</lostsyncs>
  <t3s>T3 Timeouts : 5</t3s>
  <healthproctime>26.4649</healthproctime>
  </health>
  <cpe>IP address MAC address xxxxx</cpe>
  <bridgeproctime>20.9113</bridgeproctime>
  <cmts>CMTS: something.net</cmts>
  <mac>MAC: xx07.0e07.xxb9</mac>
- <extdata>
  <macaddress>0007.0e07.2db9</macaddress>
  <ipaddress>11.212.151.157</ipaddress>
  <primsid>3801</primsid>
  <qosprofileindex>116</qosprofileindex>
  <interface>c60u5</interface>
  <sysdescr />
  <upstreampower>0.00dbmv(snr=24.63dbmv)</upstreampower>
  <downstreampower>0.00dbmv(snr=-----dbmv)</downstreampower>
  <timingoffset>2821</timingoffset>
  <initialtimingoffset>2821</initialtimingoffset>
  <receivedpower>7.50</receivedpower>
  <macversion>doc1.0</macversion>
  <qosprovisionedmode>doc1.0</qosprovisionedmode>
  <enabledocsis2.0mode>y</enabledocsis2.0mode>
  <phyoperatingmode>tdma</phyoperatingmode>
  <capabilities>{frag=n,concat=y,phs=n,priv=bpi}</capabilities>
  <sidsaidlimit>{maxussids=0,maxdssaids=0}</sidsaidlimit>

<optionalfilteringsupport>{802.1p=n,802.1q=n}</optionalfilteringsupport>


<transmitequalizersupport>{tapssymbol=0,numoftaps=0}</transmitequalizersupport>

  <numberofcpeips>0(maxcpeips=5)</numberofcpeips>
  <cfgmax-cpe>5</cfgmax-cpe>
  <flaps>5(may116</flaps>
  <errors>5crcs,0hcses</errors>
  <stnmtnfailures>0aborts,0exhausted</stnmtnfailures>
  <totalusflows>1(1active)</totalusflows>
  <totaldsflows>1(1active)</totaldsflows>
  <totalusdata>203330packets,24194640bytes</totalusdata>
  <totalusthroughput>0bitssec,0packetssec</totalusthroughput>
  <totaldsdata>77051packets,73160463bytes</totaldsdata>
  <totaldsthroughput>0bitssec,0packetssec</totaldsthroughput>
  <activeclassifiers>0(max=nolimit)</activeclassifiers>
  <dsadsxmessages>permitall</dsadsxmessages>
  <totaltimeonline>41d6h</totaltimeonline>
  </extdata>
  <extproctime>21.4699</extproctime>
  <scriptproctime>68.8469</scriptproctime> 
  </modeminfo>

5.ServerXMLHTTP.3.0 parsing problem

6. xml parsing problem

7. XML Parsing Problem in Internet Explorer

8. AJAX XML parsing problem



Return to xml

 

Who is online

Users browsing this forum: No registered users and 41 guest