• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XML Parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML Parsing


  • Subject: Re: XML Parsing
  • From: Chris Parker <email@hidden>
  • Date: Sat, 3 Nov 2001 21:26:00 -0800

Hi Angela,

You can traverse the CFTree as you've found with the various CFTree
functions. If you're looking at a specific node in the CFXMLTree (call
it curCFTreeNode), you can do something like this:

CFXMLNodeRef curXMLNode;
CFDictionaryRef curXMLDict;
CFXMLElementInfo *curXMLElement;

curXMLNode = CFXMLTreeGetNode(curCFTreeNode);
if(CFXMLNodeGetTypeCode(curXMLNode) == kCFXMLNodeTypeElement) {
curXMLElement = (CFXMLElementInfo *)CFXMLNodeGetInfoPtr(curXMLNode);
curXMLDict = (*curXMLElement).attributes;
}

and now you'll have a CFDictionary containing the attributes of the node.

The headers for CFXMLNode.h describe what the dataString and infoPtr
formats are for the various node types.

I hope this helps out.

.chris

--
Chris Parker
Cocoa Frameworks Engineer
email@hidden

On Saturday, November 3, 2001, at 02:00 AM, Angela Brett wrote:

> Hi,
>
> I've been struggling with XMLServices. I can get the XML parsed into a
> CFTree by using:
>
> tree=CFXMLTreeCreateFromData(kCFAllocatorDefault,theXML,NULL,kCFXMLParserSkipWhitespace,
> kCFXMLNodeCurrentVersion);
>
> And then I can get to the different nodes in the tree and see what they
> are using various CFTree functions. But I can't work out how to get
> attributes - i.e if in the XML is something like <thing name="Joe"
> colour="green"/> I don't know how to get the values for name and colour.
>
> Also, I'm wondering if there is a nicer way to parse (non plist) XML, I
> don't really like CoreFoundation very much.
> -- Angela Brett email@hidden
> http://acronyms.co.nz/angela
> A mathematician is a machine for turning coffee into theorems -- Paul
> Erdos
> _______________________________________________
> cocoa-dev mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >XML Parsing (From: Angela Brett <email@hidden>)

  • Prev by Date: Re: NSView for playing QuickTime Movies?
  • Next by Date: NSPixel?
  • Previous by thread: Re: XML Parsing
  • Next by thread: best MD5
  • Index(es):
    • Date
    • Thread